tmux Sessions, Windows, and Panes
tmux organizes terminal work in three levels: sessions (top-level workspaces), windows (tabs inside a session), and panes (splits inside a window).
Quick reference
Section titled “Quick reference”# Prefix: Ctrl+b
# Sessions from the shelltmux ls # list sessionstmux attach # attach to session
# Sessions from inside tmuxCtrl+b d # detach (session keeps running)Ctrl+b s # list and choose sessionCtrl+b : new-session -s x # create session without detachingCtrl+b : switch-client -t x # switch to session x
# WindowsCtrl+b c # new windowCtrl+b n # next windowCtrl+b p # previous windowCtrl+b w # list windowsCtrl+b & # kill window
# PanesCtrl+b % # split left/rightCtrl+b " # split top/bottomCtrl+b arrows # move between panesCtrl+b x # kill paneCtrl+b z # zoom paneCtrl+b ! # pane to new windowCtrl+b Space # cycle layouts
# Copy / scrollCtrl+b [ # copy modeCtrl+b ] # pasteConfig (~/.tmux.conf)
Section titled “Config (~/.tmux.conf)”In addition to the default cases, these two lines provide useful customization. Open the tmux.conf to set these:
set -g mouse onset -g history-limit 100000Default prefix
Section titled “Default prefix”All tmux shortcuts start with the prefix key. Press it, release, then press the next key.
Ctrl+bSessions
Section titled “Sessions”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 defaulttmux new -s ml # new named session# -s: session nametmux ls # list sessionstmux attach -t ml # attach to session# -t: targettmux kill-session -t ml # kill a sessiontmux 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 attachedCtrl+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
Section titled “Session navigation from inside tmux”These are all used from inside a running tmux session.
Ctrl+b s # open interactive session list, choose with arrows + EnterCtrl+b : new-session -s x # create a new named session without detaching# -s: session nameCtrl+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
Section titled “Windows”Windows are tabs inside a session.
Ctrl+b c # new windowCtrl+b n # next windowCtrl+b p # previous windowCtrl+b 0 # go to window 0 (1, 2, ... also work)Ctrl+b w # list windows and choose oneCtrl+b , # rename current windowCtrl+b & # kill current windowPanes are splits inside a window.
Ctrl+b % # split left/rightCtrl+b " # split top/bottomCtrl+b Left/Right/Up/Down # move between panesCtrl+b o # move to next paneCtrl+b ; # jump back to previous paneCtrl+b q # show pane numbers brieflyCtrl+b x # kill current paneCtrl+b ! # turn pane into its own windowCtrl+b z # zoom pane full-screen (toggle)Ctrl+b Space # cycle pane layoutsCtrl+b Ctrl+Left/Right/Up/Down # resize paneexit # close pane from shellCtrl+d # close pane from shellCopy mode and scrollback
Section titled “Copy mode and scrollback”Scroll with arrow keys, PageUp, PageDown.
Ctrl+b [ # enter copy modeCtrl+b ] # paste copied textMouse 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
Section titled “Help and command prompt”Ctrl+b ? # show all key bindingsCtrl+b : # open tmux command promptCtrl+b Ctrl+b # send literal Ctrl+b to program inside tmux