0

I would like to on ssh login, change directory to my previous one. (I'm the only user on my machine).

1

This is what I did.

# in .bash_logout
pwd > ~/.last_dir

# in .bashrc
cd "$(cat ~/.last_dir)"
  • In Bash you can do this without cat: cd "$(< ~/.last_dir)" – Kamil Maciorowski Nov 27 '20 at 22:47

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.