tmux organizes terminal work in three levels: sessions (top-level workspaces), windows (tabs inside a session), and panes (splits inside a window).
Quick reference
# Prefix: Ctrl+b
# Sessions from the shell
tmux ls # list sessions
tmux attach # attach to session
# Sessions from inside tmux
Ctrl+b d # detach (session keeps running)
Ctrl+b s # list and choose session
Ctrl+b : new-session -s x # create session without detaching
Ctrl+b : switch-client -t x # switch to session x
# Windows
Ctrl+b c # new window
Ctrl+b n # next window
Ctrl+b p # previous window
Ctrl+b w # list windows
Ctrl+b & # kill window
# Panes
Ctrl+b % # split left/right
Ctrl+b " # split top/bottom
Ctrl+b arrows # move between panes
Ctrl+b x # kill pane
Ctrl+b z # zoom pane
Ctrl+b ! # pane to new window
Ctrl+b Space # cycle layouts
# Copy / scroll
Ctrl+b [ # copy mode
Ctrl+b ] # pasteConfig (~/.tmux.conf)
In addition to the default cases, these two lines provide useful customization. Open the tmux.conf to set these:
set -g mouse on
set -g history-limit 100000Default prefix
All tmux shortcuts start with the prefix key. Press it, release, then press the next key.
Ctrl+bSessions
Sessions are top-level workspaces. They keep running even if you close the terminal, until you kill them or reboot.
From the shell (outside tmux):
tmux # new unnamed session, named 0 by default
tmux new -s ml # new named session
# -s: session name
tmux ls # list sessions
tmux attach -t ml # attach to session
# -t: target
tmux kill-session -t ml # kill a session
tmux kill-server # kill the whole tmux serverIf you started with just tmux the session is called 0. To rename it afterwards:
tmux rename-session mysession # from the shell while attached
Ctrl+b $ # from inside tmuxFrom inside a running tmux session:
Ctrl+b d # detach and returns you to the shell, session keeps runningSession navigation from inside tmux
These are all used from inside a running tmux session.
Ctrl+b s # open interactive session list, choose with arrows + Enter
Ctrl+b : new-session -s x # create a new named session without detaching
# -s: session name
Ctrl+b : switch-client -t x # jump to an existing session by nameCtrl+b : opens the tmux command prompt at the bottom of the screen. Type the command after the colon and press Enter.
Windows
Windows are tabs inside a session.
Ctrl+b c # new window
Ctrl+b n # next window
Ctrl+b p # previous window
Ctrl+b 0 # go to window 0 (1, 2, ... also work)
Ctrl+b w # list windows and choose one
Ctrl+b , # rename current window
Ctrl+b & # kill current windowPanes
Panes are splits inside a window.
Ctrl+b % # split left/right
Ctrl+b " # split top/bottom
Ctrl+b Left/Right/Up/Down # move between panes
Ctrl+b o # move to next pane
Ctrl+b ; # jump back to previous pane
Ctrl+b q # show pane numbers briefly
Ctrl+b x # kill current pane
Ctrl+b ! # turn pane into its own window
Ctrl+b z # zoom pane full-screen (toggle)
Ctrl+b Space # cycle pane layouts
Ctrl+b Ctrl+Left/Right/Up/Down # resize pane
exit # close pane from shell
Ctrl+d # close pane from shellCopy mode and scrollback
Scroll with arrow keys, PageUp, PageDown.
Ctrl+b [ # enter copy mode
Ctrl+b ] # paste copied textMouse
Mouse support is enabled via set -g mouse on.
- Click a pane to select it
- Click a window in the status bar to switch to it
- Scroll with the mouse wheel or touchpad
- Drag pane borders to resize panes
Help and command prompt
Ctrl+b ? # show all key bindings
Ctrl+b : # open tmux command prompt
Ctrl+b Ctrl+b # send literal Ctrl+b to program inside tmux