Set CDPATH to ease folder navigation
CDPATH is an environment variable which tells the
cd command where to look for the specified folder. By including the parent folders of commonly used locations you can access folders more easily - and without typing an entire path.
Open up your shell profile file
.bashrc (Linux) or
Somewhere near the bottom of the file add a line to set the CDPATH environment variable:
In order left to right this tells
cd to look in:
- The current directory (blank; before the first
- The parent directory
- Your home directory
- Your projects directory in your home
You can add as many folders to search as you like and these will be checked in order from left to right.
Restart your shell (close and reopen or enter
restart) and then try to
cd to folders in your home directory from anywhere on your filesystem with
cd <foldername> and no path.
- Bash Command Substitution
- Find all running processes of a program
- Customize directory colors
- Collaborate in the shell with screen (multiuser)
- Show Warning in Prompt when Shell Loses Directory
Get my latest Python projects, tips & tutorials direct to your Inbox.