Original headline: “These 3 simple bash variables add bookmarks and back buttons to your Linux terminal session”

CDPATH, cd -, and pushd/popd, with CDPATH for bookmarks and cd - for back navigation.

CDPATH lets you jump to bookmarked directories via CDPATH=.:~/projects:~/Documents/writing in ~/.bashrc. cd - toggles between the last two directories using OLDPWD. pushd/popd maintains a full directory stack for complex navigation.

CDPATH setup
Add CDPATH=.:~/projects:~/Documents/writing to ~/.bashrc and avoid exporting it to prevent script conflicts.
cd - behavior
Toggles between last two directories using OLDPWD, supports ~- shortcut.
pushd/popd stack
Maintains DIRSTACK array, use dirs -v for indexed navigation.

Stated by the source · Technology · How-To Geek · · Read the original →

Last checked

Would naming it have hurt?