Search code examples
tmuxiterm2

Attach to specific tmux session using Iterm2


I know that I can connect iterm2 to a tmux session using tmux -CC attach. However, I don't know how to attach Iterm2 to a specific tmux session if I have more than 1 running at a time.


Solution

  • You can use tmux -CC attach -t SESSION_NAME to attach to a specific session.

    If you run this from iTerm, it starts a new iTerm window with all the panes you had in that session loaded as iTerm native panes.

    Eg. If tmux ls shows sessions 0, 1, 2, tmux -CC attach -t 1 will attach to session 1.

    Eg. If tmux ls shows sessions projectA and projectB, tmux -CC attach -t projectA will attach to the session named projectA.