Harshal Bhakta

I am the co-founder of TeachMore.

Quickly switch directory in terminal

04 Jan 2019 » mac, ubuntu, terminal

Here’s a quick hack to quickly switch directory in terminal. It comes in handy when I am simultaneously working on multiple projects.

Before

$ cd ~/arena/iw/projects/teachmore/TeachMoreWeb
$ .
$ . Do something awesome for the first project!
$ .
$ cd ~/arena/eec/projects/eecglobal/EecGlobalWeb
$ .
$ . Do something awesome for the second project!
$ .
$ cd ~/arena/iw/projects/teachmore/TeachMoreAndroid

After

$ gototmw
$ .
$ . Do something awesome for the first project!
$ .
$ gotoeecw
$ .
$ . Do something awesome for the second project!
$ .
$ gototma

How to do this?

We use Aliases to do this. We are basically creating shortcuts for above commands using Aliases. It saves us a lot of keystrokes.

# Put below lines in ~/.bash_profile (For Mac) or ~/.bashrc (For Ubuntu)
alias gototmw="cd ~/arena/iw/projects/teachmore/TeachMoreWeb"
alias gotoeecw="cd ~/arena/eec/projects/eecglobal/EecGlobalWeb"
alias gototma="cd ~/arena/iw/projects/teachmore/TeachMoreAndroid"

That’s it. Set your keyboards on fire 🔥

via GIPHY