Linux terminal trick: Hack the CD command to remember where you've been
redhat.com
redhat.com
One thing that annoys me is that popd consumes the top of the stack, which I something don't want. I put this in my bashrc some years ago which basically executes a popd but doesn't pop the stack:
alias peekd='cd "$(dirs -l -p | sed -n '\''2{p;q}'\'')"'