Blog Tags: 

CDPATH

I used bash for a decade or so before I discovered this little highly useful gem a few years back. Nowadays I can't remember what I used to do without it.

From the bash manual page:

CDPATH

The search path for the cd command.  This is  a  colon-separated
list of directories in which the shell looks for destination
directories specified by the cd command.

A sample value is ".:~:/usr".

I've added the following to my .bashrc:

CDPATH=.:/turnkey:/turnkey/projects:/turnkey/appliances

Now this works:

cd tklbam # takes me to /turnkey/projects/tklbam
cd core   # takes me to /turnkey/appliances/core
cd notes  # takes me to /turnkey/notes

For best results, turn on bash auto completion:

apt-get install bash-completion

Add new comment