cd'ing to frequently-used directories in ZSH

Josh just dropped some sweet, sweet ZSH knowledge. I spend a lot of time in the directories under $HOME/thoughtbot/ and $HOME/src, and to get there I type (for example) cd ~/thoughtbot/hoptoad. There is a better way!

First, add this to your ~/.zshrc and source it:

setopt auto_cd
cdpath=($HOME/thoughtbot $HOME/src)

Obviously, use different paths in cdpath depending on which directories you cd into a lot.

Now let’s try it out:

$ cd rspec-core # Autocompleted from rspe<TAB>
$ pwd
$ cd hoptoad
$ pwd

Seriously, check out your coworkers’ dotfiles. It can improve your workflow efficiency by an order of magnitude. Like most of the thoughtbot crew, Josh keeps his dotfiles on Github.