Skip to main content
Post Made Community Wiki
Source Link
Michael Mrozek
  • 95.8k
  • 40
  • 245
  • 236

You can use CDPATH to set up the directory equivalent of PATH; if you try to cd foo and there is no foo in the current directory, the shell will check each of the directories in CDPATH looking for foo in them, and switch to the first one it finds:

export CDPATH="/usr" cd bin # switches to 'bin' if there is one in the current directory, or /usr/bin otherwise