tmux-plugins / tmux-resurrect

Persists tmux environment across system restarts.
MIT License
11.42k stars 424 forks source link

Restore nested tmux session on a remote server #423

Closed yzhou61 closed 2 years ago

yzhou61 commented 2 years ago

Hi, I apologize if this has been addressed before. I have a tmux session on my local machine, with multiple windows of ssh sessions to different servers. Each server runs a tmux session on its own.

When I restore my local tmux, I get all the windows back, with restored ssh sessions, which is great. But it will be even better if the tmux session on the server is also restored. Basically I'm asking if a tmux a can be executed automatically upon ssh connection.

Thanks.

bruno- commented 2 years ago

You can probably script this. I'm using a simple shell script ssht to automatically attach or create a new tmux session on the target server

#!/usr/bin/env bash

ssh $* -t 'tmux attach || tmux'

Check how is this script program saved locally, and make sure it's restored via set -g @resurrect-processes.

yzhou61 commented 2 years ago

Thanks. That worked and is a pretty elegant solution.