//View Tip #185
Similar Tips
» Deleting whole words on a bash command line
» Filter stderr for cron jobs
» Close shell keeping all subprocess running
» another solution to #67
» Checksum directory recursively

 

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 »




Comments 

Add your comment

Comments are currently disabled
csuttles
This is awesome. It changed my life. It requires bash-completion to really rock your socks off.
Posted 2009-07-11 01:25:40
goga
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