//View Tip #185
Similar Tips
» Get your IP in one line
» swap files
» SSH Auto Complete
» Find files greater than a certain size
» Find occurrences of a string in a large code base without firing


Latest tips by RSS
Click here to subscribe
Follow Shell-Fu on Twitter
Click here to follow
Follow Shell-Fu on identi.ca
Click here to follow
This is a little known and very underrated shell variable. CDPATH does for the cd built-in what PATH does for executables. By setting this wisely, you can cut down on the number of key-strokes you enter per day.

For example:
$ export CDPATH='.:~:/usr/local/apache/htdocs:/disk/backups'

Now, whenever you use the cd command, bash will check all the directories in the $CDPATH list for matches to the directory name.

View Comments »


Add your comment

Comments are currently disabled
This is awesome. It changed my life. It requires bash-completion to really rock your socks off.
Posted 2009-07-11 01:25:40
This is not just a bash trick. It works in any POSIX shell.
Posted 2009-07-31 09:15:29
I found that bash-completion works for ., but not any of the other paths in CDPATH... What am I doing wrong?
Posted 2009-11-05 04:00:42

Home Latest Browse Top 25 Random Hall Of Fame Contact Submit