CDPATH
is an environment variable in Unix-like shells such as Bash and Zsh that allows for quick directory navigation. It holds a list of directories that the cd
command will search when you attempt to change directories.
Setting Up CDPATH
To set up CDPATH
, add the following export
statement to your .bashrc
or .zshrc
:
Apply the changes by either sourcing your shell’s configuration file (~/.bashrc
or ~/.zshrc
) or launching a new shell session with commands like exec -l zsh
.
Usage Example
Assume CDPATH
is set as follows:
cd my_app
: Takes you to/home/user/projects/my_app
, regardless of your current location, if the directory exists.cd etc
: Takes you to/usr/local/etc
if it exists.