Environment & Shell Customization (Aliases/Functions/.Bashrc)
Stop doing the `cd -` dance between folders
đź§© The Challenge
Constantly bouncing between a few key directories? You’re in `~/dev/project-foo/frontend`, then need to check logs in `/var/log/project-foo`, then jump to `/etc/project-foo` for config. Typing those paths or spamming `cd -` is a real time suck.
đź’ˇ The Fix
Your shell has a secret weapon: a directory stack. It lets you “bookmark” directories as you visit them, then quickly jump back or forward through your recent locations without typing a thing.
# Let's start in your home directory
pushd ~/dev/project-foo/frontend
pushd /var/log/project-foo
pushd /etc/project-foo
dirs -v
# Now you're in /etc/project-foo.
# Jump straight back to ~/dev/project-foo/frontend (it's index 2 from 'dirs -v' output)
pushd +2
# Done with this location for now, pop it off and go back to where you were before
popd
⚙️ Why It Works
`pushd` adds a directory to your shell’s stack and changes to it. `dirs -v` shows you the numbered list of “bookmarked” paths. `pushd +N` rotates the stack so directory N becomes the current one, and `popd` removes the current directory and shifts you to the *new* top of the stack.
🚀 Pro-Tip: Alias `d` to `dirs -v` for a quick peek at your stack.
Linux Tips & Tricks | © ngelinux.com | 9/10/2026
