Stop your shell from burying your most used directories

Environment & Shell Customization (Aliases/Functions/.Bashrc)

Stop your shell from burying your most used directories

🧩 The Challenge

Everyone hits that point where they are bouncing between three deep, annoying path structures for a project and keep typing the same long path over and over. I’ve wasted so much time hitting tab completion for nested directories that I eventually just started keeping a notepad file open.

💡 The Fix

Use the CDPATH variable to turn your home directory into a search hub. It makes your shell look through specified parent folders whenever you try to change directory, so you can just type the folder name from anywhere.

CDPATH='.:~:/var/www:/opt/projects'
export CDPATH

⚙️ Why It Works

Setting this variable tells bash to append your current working directory search logic to include the paths listed, so you don’t have to provide the full absolute path every time. It’s a total game changer once your fingers get used to it.

🚀 Pro-Tip: Keep the current directory represented by the dot at the start of your CDPATH so you don’t break expected behavior when working inside local subfolders.

Linux Tips & Tricks | © ngelinux.com | 7/26/2026

0 0 votes
Article Rating
Subscribe
Notify of
guest

0 Comments
Newest
Oldest Most Voted