Bash: Shortcuts to your favorite directories with CDPATH

This is a fairly handy trick.

I’m always logging in to different servers, which all have a different location for their logs. With this trick you can login and just type “cd logs” from anywhere.

First we will add our directory to the CDPATH variable:

joris@badattitude /data/share/my_domain
$ echo $CDPATH

joris@badattitude /data/share/my_domain
$ export CDPATH=/data/share/my_domain

joris@badattitude /data/share/my_domain
$ echo $CDPATH

Then we’ll check if it is working:

joris@badattitude ~
$ cd logs

joris@badattitude /data/share/my_domain/logs

Awesome, we’ve arrived in our logs directory straight from our homedir!


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s