iTerm2 & tmux & ssh

iTerm2 offers nice tmux integration, I’m trying to get into the habit of automatically using tmux for all remote SSH sessions, in case my internet connection disconnects while I’m running commands on a remote machine. If I get disconnected, I can easily go back to the task I was doing when I’m back online.

This is another friendly reminder to my future self to always do this. I had this happen way too often: executing a long-running command on a remote machine, being disconnected from the SSH session and to have to start over. I use the following command to either jump into an existing tmux session, or create a new one if there’s none:

ssh jonas@server -t 'tmux -CC a || tmux -CC'