As other have suggested, writing your current directory to your .bash_history
can get you back to it.
But on the fly, see if pushing the current directory on to the stack and poping back to it later might be what you need.
pushd .
cd /else/where/
popd
you can also push as many directories. Poping them one at a time will revert the working directory back in the pushed order.
pushd .
saves the current directory (don't forget the dot .
),
cd
changes working directory,
popd
brings you back to the last pushed (saved) directory.
These commands will also show you the folder you have saved in their respective order every time you push or pop.
and when entering the command history
, you will be able to track back the changes made in each directory afterwards.
pwd >> ~/.bash_history
?