From the command line
tmux
to enter a new tmux session.
tmux a
to attach to an existing tmux session (and tmux a 3
to attach to tmux session #3)
tmux new -s session_name
to create a new tmux session with session name session_name.
tmux a -t session_name
to attach to an existing tmux session with session name session_name.
Normal usage
If you haven't customized anything, Ctrl+b is the default prefix.
Ctrl+b d
to detach from the current tmux session
Ctrl+b c
to create a new window (think of windows as tabs in a tabbed interface, which are new terminals) and switch to it.
Ctrl+b 0
to switch to window #0 (all the numbers work, though I'm not sure about 10+)
Ctrl+b n
to switch to the next window.
Ctrl+b p
to switch to the previous window (as ordered by numbers, not by recently-visited).
Ctrl+b &
to close the current window (not sure how this interacts with running commands yet).
Ctrl+b %
to split the current window into panes vertically.
Ctrl+b "
to split the current window into panes horizontally.
Ctrl+b arrow-keys
to switch to other panes in current window.
Ctrl+b q
to show pane numbers.
Ctrl+b q 1
to switch to pane #1.
Ctrl+b x
to close current pane (again, not sure how this interacts with running commands).
Ctrl+b o
to switch to next pane.
Also by default, the mouse does nothing when you're inside tmux - you need to add something to your .tmux.conf file to enable the mouse.
Copy mode
Ctrl-b + [
to enter copy mode
Ctrl+Space
to start selection
Alt+w
or Ctrl+w
to copy
q
to quit copy mode
Ctrl-b + ]
to yank
Normal Emacs for navigation
On Mac, if you want to highlight some text from a tmux session, you can use Function + Mouse to select. I have Caps Lock mapped to Function. (Almost for sure there's a way to integrate tmux copy-mode with MacOS, but for now haven't gotten it to work)
If you hit Ctrl+S, you will lock the terminal, and you have to hit Ctrl+Q to unlock it again. (General terminal guidance when you're on the command line) Link
Oops
If you get stuck in a nested tmux, you can use Ctrl+B, Ctrl+B, D to detach from the inner tmux session.