bash cdpath magic

written by justin on April 17th, 2008 @ 02:57 PM

While perusing the bash man page today I found something pretty interesting. There is a variable that you can set in your .bash_profile file that is a search path for the cd command. That means that you can create a path with your most used cd locations and you can always get to those locations with a simple cd <foldername>. I added my work directory for web applications:


export CDPATH=.:~:/Users/jkay/Sites

Now a simple cd essence will get me to /Users/jkay/Sites/essence from anywhere.

Post a comment