Moving quickly from anywhere with $CDPATH

  • HOME
  • >
  • BASH
  • >
  • Moving quickly from anywhere with $CDPATH
Last Updated: 
Tags:  bash cd linux

Do you know the environment variable $CDPATH? This variable let you define some path where to look for a directories when moving with the command CD. You can define multiple path in this variable. This can be usefull if you have some directories that you access more frequently than the others. As this variable define the order how you move from a directory to another, I suggest you to keep the "." directory in first position of your variable declaration. Of course, you can set this variable in your .bashrc

[root@host ~]$ export CDPATH=.:/:~/  
[root@host ~]$ cd usr
/usr
[root@host /usr]$ cd Desktop
/home/nicolas/Desktop
Related bash posts that you may like
What is the Bash Null Command?
Learn about the Bash null command, also known as the POSIX shell colon command. This post cover concrete use cases and pitfalls to avoid.
How To Format Date and Time in Linux, macOS, and Bash?
Find out how to manipulate date and time on linux and macOS systems as well as natively in the Bash shell. This post covers all you need to know to format a date from your shell.
How To Use Option as Meta Key in macOS Terminal?
The Meta Key is a modifier key that can be quite helpful to improve your productivity while working in a terminal and bash. This post cover how to enable from the command line the Meta Key in macOS Terminal.