I just found out about this today, and it kinda blew me away.
there’s an environment variable in bash ‘CDPATH’ that checks to see what the directory names are for easy transitioning from directory to directory. Normally the cdpath variable is just . Tab completion helps immensely with this, but this is still much faster:
to get from ~/ to ~/work/puppet/modules/my_module I’d normally type
but when I’ve added ~/work/puppet/modules to my cdpath, I just have to type
I added a few common directories I store my projects into to this, and viola! yay!
here’s what I did to set it up:
$ mkdir .bash $ cd .bash $ cat << EOF >> cdpath.sh > #!/bin/bash > export CDPATH='.:~:~/git:~/git/puppet:~/git/puppet/modules' > EOF $ chmod +x cdpath.sh
Now you just have to add this to your startup scripts. I'd just append the following to my .bash_profile and call it a day:
$ echo 'source ~/.bash/cdpath.sh' >>~/.bash_profile
~$ pwd /Users/wolf ~$ cd common /Users/wolf/git/puppet/modules/common ~/git/puppet/modules/common (master)$ cd hieradata /Users/wolf/git/puppet/hieradata ~/git/puppet/hieradata (master)$ cd ~ ~$
Hope this helps someone else!