Environment & Shell Customization (Aliases/Functions/.Bashrc)
Stop hunting for that one specific directory in your bash history
đź§© The Challenge
You know you navigated to some deep, obscure config folder last Tuesday, but your history is just a wall of identical cd commands that tell you absolutely nothing. Spending ten minutes pressing the up arrow is a special kind of hell I wouldn’t wish on anyone.
đź’ˇ The Fix
Throw a small snippet into your bashrc that writes the absolute path of every directory you enter into a separate, searchable file. It makes jumping back into deep file structures a one-second operation instead of a guessing game.
export PROMPT_COMMAND='pwd >> $HOME/.directory_history'
alias gh='cd $(tail -n 20 ~/.directory_history | sort -u | fzf)'
⚙️ Why It Works
By hooking into PROMPT_COMMAND, you’re effectively keeping a clean, persistent log of every directory you’ve actually visited. Tying that into a simple alias with fzf lets you fuzzy-match your way back to that folder you swear you were just in.
🚀 Pro-Tip: Stick a uniq command in that pipe if you want to keep the history file from growing to a million lines overnight.
Linux Tips & Tricks | © ngelinux.com | 8/26/2026
