From a POSIX shell `$OLDPWD` holds the name of the previous working directory:
cd /tmp
echo You are here: $PWD
echo You were here: $OLDPWD
cd $OLDPWD
@YesIKnowIT Neat :) Not being POSIX that doesn’t work for me in Fish shell but Alt+left-arrow goes to the previous working directory and Alt+right-arrow goes to the next.
@hyde @YesIKnowIT Ah, yes, I’d misremembered it as cd -1 yesterday while trying out the posix stuff in fish and was wondering why it wasn’t working :)
@aral with zsh, it works with cd -1 too
@hyde Ah, then that’s where I remember it from. I was on zsh before fish :)