I\'ve been Googling for a while looking for a simple way to do this, and I can\'t find one.
I have a custom terminal environment set up (zsh) with various aliases and fu
In my answer here, I provided a function and an alias:
function cd () { command cd "$@"; echo "$PWD" > /tmp/CWD; } export cd alias cdp='cd $(cat /tmp/CWD)'
You should be able to put a (possibly conditional) statement at the end of your ~/.bashrc or ~/.zshrc to execute that alias.
~/.bashrc
~/.zshrc