Skip to content

Instantly share code, notes, and snippets.

@BigW72
Last active January 20, 2020 16:03
Show Gist options
  • Save BigW72/be5b7504d7eea2f5b85c3967593d3618 to your computer and use it in GitHub Desktop.
Save BigW72/be5b7504d7eea2f5b85c3967593d3618 to your computer and use it in GitHub Desktop.
Start tmux by attaching to an existing session if it exists or creating a new one if one doesn't exist

Attach to exising tmux session or create a new one

Create a new tmux session called 'main' if there is no existing session called 'main', otherwise attach to the existing 'main' session.

From an answer on https://unix.stackexchange.com/questions/103898/how-to-start-tmux-with-attach-if-a-session-exists

To ssh from iTerm2 on macOS

Add a -t switch to the ssh command for the profile. Works for me ssh'ing to an Ubuntu 18.04 host.

ssh -t <hostname> tmux new-session -A -s main

Run locally in iTerm2 on macOS

Enter the following as the command in the General tab of the profile.

tmux new-session -A -s main
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment