Skip to content

Preserve WT_SESSION across restarts #6362

@davidchisnall

Description

@davidchisnall

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Area-UserInterfaceIssues pertaining to the user interface of the Console or TerminalIssue-TaskIt's a feature request, but it doesn't really need a major design.Needs-Tag-FixDoesn't match tag requirementsProduct-TerminalThe new Windows Terminal.

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions