Command line tips for quick navigation in the terminal

terminal
navigation
tips
Quick tips for quick navigation in the terminal
Published

October 4, 2020

Things I wish I had knew earlier.

Most of the tips are from here

Basics

Navigation to any folder

> cd /home/andras/Projects/data_science_blog/
/home/andras/Projects/data_science_blog

With the ~ we can jump to our home folder

> cd ~
/home/andras

cd

We do not even need the ~ to navigate to our home folder.

> cd /
/
> cd
/home/andras

Bash function

We can also create a bash function so we can spare even typing cd

Here is the function

# .bashrc

function blog() {
    cd "$HOME/Projects/data_science_blog"
}

And jump!

> blog
/home/andras/Projects/data_science_blog

cd -

With - we can jump back to our previous folder

> cd -
/home/andras/Projects/data_science_blog

Path variable in .bashrc

A further option is to create a variable in bash

# .bashrc
BLOG=/home/andras/Projects/data_science_blog
cd $BLOG
/home/andras/Projects/data_science_blog

Create an alias

# .bashrc
alias ds_blog="cd /home/andras/Projects/data_science_blog"
> ds_blog
/home/andras/Projects/data_science_blog