问题原文
原帖链接 · Jake Wilson · CC BY-SA 3.0
During my multitasking days, sometimes I will be booted off of an SSH session for one reason or another (idle timeouts, etc), while I am working on another task. When I return to the terminal, I will find myself back at localhost, needing to SSH back to the server. Once back at the server, I'm always in my ~ home directory by default and I need to navigate back to the directory I was at last (if I can remember it) in order to continue working.
Is it possible to automatically return to the last directory I was working in when I login?
I was thinking a homebrew solution would be aliasing cd to change directories but also save that directory into some environment variable, and then changing to that directory in my .bash_profile.
But is there any sort of functionality like this already in Linux?
社区高分解答
原帖链接 · 200_success · CC BY-SA 3.0
Instead of solving the cd persistence problem, you should consider solutions to resume your shell session.
tmux- Inside SSH, run
tmuxto start a new session - If disconnected, SSH in again, and run
tmux attachto resume the session - Inside a
tmuxsession, you can press CtrlB, then D to detach
- Inside SSH, run
screen- Inside SSH, run
screento start a new session - If disconnected, SSH in again, and run
screen -rto resume the session - Inside a
screensession, you can press CtrlA, then D to detach
- Inside SSH, run
moshmoshis an SSH replacement that runs over UDP and is designed to be resistant to network disruptions
摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。
