-
Notifications
You must be signed in to change notification settings - Fork 9.1k
Description
The macOS terminal (and iTerm, I believe) provide an environment variable analogous to WT_SESSION that is preserved across application restarts. When the terminal restarts, it will recreate all of the windows and tabs in their original position and with the same working directory.
I use this feature to preserve ssh sessions across restarts. I use a shell function to wrap ssh. This function creates a file in a specific location whose name is the terminal session ID and whose contents is the connection string. It then starts a tmux session on the remote end whose session ID is the terminal session ID. In .bashrc, I check whether a file exists describing the current session and, if so, automatically reconnect.
When I install software updates on my Mac, the terminal is killed and all of my remote connections resume after the reboot. A Windows update was forcibly installed last night causing WT to exit and I lost all of my existing connections and spent 10 minutes this morning restoring the state for my working environment.