small trick for bash
If you want to remember last working directory you can add this into .bashrc
# cdp() will create or rewrite file ~/.cwd with working path
cdp()
{
cd "$1"
echo `pwd` > ~/.cwd
}
# exporting cdp() to shell as a command
export -f cdp
# changing working directory if file exists
if [ -d `cat ~/.cwd` ]; then
cd `cat ~/.cwd`
fi