Deep Reference

Every tmux Command Explained

tmux commands are issued either from the shell (tmux <command>), from inside tmux via command mode (Prefix :), or directly as key bindings. This page covers the commands you will use day to day, with their most useful flags and copy-ready examples, checked against tmux 3.7c. For the complete upstream option list, see the searchable man tmux page.

The commands you will actually use

If you are new to tmux, these cover most day-to-day work. Everything else is documented below.

What you want to doCommand
Start a sessiontmux new -s work
List sessionstmux ls
Reattach to a sessiontmux attach -t work
Detach and leave it runningPrefix then d
Split the windowPrefix then % or "
Move between panesPrefix then an arrow key
Kill a sessiontmux kill-session -t work

Session Commands

Sessions are the top level of the tmux hierarchy. A session groups multiple windows and continues running in the background even after you detach. Sessions survive SSH drops and can be reattached from any terminal.

bash — session commands

# Create sessions

$ tmux new-session -s mysession # create and attach

$ tmux new-session -s mysession -d # create detached (background)

$ tmux new -s mysession -c ~/projects # set starting directory


# List sessions

$ tmux ls

$ tmux list-sessions

$ tmux ls -F '#{session_name}: #{session_windows} windows'


# Attach sessions

$ tmux attach -t mysession # attach by name

$ tmux attach # attach to most recent

$ tmux attach -t mysession -d # detach other clients first


# Detach, rename, kill

$ tmux detach-client # detach (also: Prefix d)

$ tmux rename-session -t old new # rename session

$ tmux kill-session -t mysession # kill one session

$ tmux kill-server # kill ALL sessions and server

$ tmux has-session -t mysession && echo "exists"

CommandAlias / ShortKey BindingDescription
new-session -s namenew -s name—Create a new named session
list-sessionsls—List all sessions
attach-session -t nameattach -t name—Attach to a named session
detach-client—Prefix dDetach from current session
rename-session -t old new—Prefix $Rename a session
kill-session -t name——Kill a specific session
kill-server——Kill tmux server and all sessions
has-session -t name——Check if session exists (returns 0/1)
switch-client -t nameswitchc—Switch this client to another session
choose-tree -s—Prefix sPick a session from an interactive tree
switch-client -l—Prefix LSwitch to the last (previously used) session
switch-client -p—Prefix (Switch to previous session
switch-client -n—Prefix )Switch to next session

Window Commands

Windows are tabs inside a session. Each window has its own set of panes and occupies the full terminal space. Use windows to organize different tasks within the same session.

bash — window commands

$ tmux new-window -n logs # new window named 'logs'

$ tmux new-window -t dev:2 # new window at index 2 in 'dev'

$ tmux rename-window monitoring # rename current window

$ tmux select-window -t :2 # go to window index 2

$ tmux next-window # (Prefix n)

$ tmux previous-window # (Prefix p)

$ tmux last-window # toggle last window (Prefix l)

$ tmux kill-window -t :2 # kill window at index 2

$ tmux move-window -t dev:3 # move current window to session:index

$ tmux swap-window -s 2 -t 3 # swap window positions

$ tmux list-windows # list windows in current session

CommandKey BindingDescription
new-window -n namePrefix cCreate new window (with optional name)
rename-window namePrefix ,Rename current window
select-window -t :NPrefix 0-9Select window by number
next-windowPrefix nMove to next window
previous-windowPrefix pMove to previous window
last-windowPrefix lToggle between last two windows
choose-tree -wPrefix wInteractive window chooser (all sessions)
list-windows—Print windows in the current session
find-window -N namePrefix fSearch windows by name
kill-window -t :NPrefix &Kill a window and all its panes
move-window -t session:NPrefix .Move window to another session/index
swap-window -s N -t M—Swap position of two windows
move-window -r—Renumber windows to remove gaps in sequence

Pane Commands

Panes are splits within a window. Each pane runs an independent shell. Panes can be resized, swapped, zoomed, and moved between windows.

bash — pane commands

# Splitting

$ tmux split-window -h # split horizontally (side by side)

$ tmux split-window -v # split vertically (top/bottom)

$ tmux split-window -h -l 30% # split, new pane gets 30% width

$ tmux split-window -h -c "#{pane_current_path}" # split, same directory


# Navigation

$ tmux select-pane -L # move focus left

$ tmux select-pane -R # move focus right

$ tmux select-pane -U # move focus up

$ tmux select-pane -D # move focus down

$ tmux select-pane -t :.+ # move to next pane (Prefix o)


# Resize Pane Commands

$ tmux resize-pane -L 10 # resize pane left by 10 cells

$ tmux resize-pane -R 10 # resize right by 10 cells

$ tmux resize-pane -U 5 # resize up by 5 lines

$ tmux resize-pane -D 5 # resize down by 5 lines

$ tmux resize-pane -Z # toggle zoom (fullscreen)


# Other operations

$ tmux kill-pane -t :. # kill current pane

$ tmux swap-pane -s :1 -t :2 # swap two panes

$ tmux break-pane # break pane into new window

$ tmux join-pane -s :2 -t :1 # merge window into pane

$ tmux display-panes # show pane numbers (Prefix q)

# Floating panes (tmux 3.7+, early feature) - full guide: tmux.app/doc/floating-panes/

$ tmux new-pane # floating pane over the layout (Prefix *)

$ tmux new-pane -x 80 -y 20 htop # 80x20 floating pane running htop

Default Key Bindings (Prefix: Ctrl+b)

All default key bindings after pressing the prefix key (Ctrl+b). List all with: tmux list-keys or Prefix ?.

BindingActionCategory
Prefix cCreate new windowWindows
Prefix n / pNext / Previous windowWindows
Prefix lLast (toggled) windowWindows
Prefix 0–9Select window by numberWindows
Prefix wInteractive window chooserWindows
Prefix ,Rename current windowWindows
Prefix &Kill current windowWindows
Prefix %Split pane horizontallyPanes
Prefix "Split pane verticallyPanes
Prefix ↑↓←→Navigate between panesPanes
Prefix oSelect next panePanes
Prefix zToggle pane zoom (fullscreen)Panes
Prefix xKill current panePanes
Prefix qShow pane numbersPanes
Prefix { / }Swap pane backward / forwardPanes
Prefix !Break pane into new windowPanes
Prefix SpaceCycle through pane layoutsPanes
Prefix Ctrl+↑↓←→Resize pane by 1 cell (repeatable)Panes
Prefix Alt+↑↓←→Resize pane by 5 cells (repeatable)Panes
Prefix Alt+1 … Alt+7Preset layouts: even-horizontal, even-vertical, main-horizontal, main-vertical, tiled, and mirrored main layouts (6–7, tmux 3.5+)Panes
Prefix ESpread panes out evenlyPanes
Prefix m / MMark pane / clear marked panePanes
Prefix *New floating pane (tmux 3.7+)Panes
Prefix dDetach from sessionSessions
Prefix sInteractive session chooserSessions
Prefix $Rename current sessionSessions
Prefix [Enter copy modeCopy
Prefix ]Paste from bufferCopy
Prefix =Choose paste buffer from listCopy
Prefix :Open command-line promptMisc
Prefix ?List all key bindingsMisc
Prefix tShow clock in current paneMisc
Prefix DChoose client to detachMisc
Prefix LSwitch to last sessionSessions
Prefix /Describe what a key doesMisc
Prefix CCustomize mode: browse and edit options and key bindingsMisc
Prefix iShow window/pane info in the status lineMisc
Prefix ~Show message logMisc
Prefix < / >Window / pane context menusMisc

Copy Mode Commands

Copy mode lets you scroll through pane history, search, and copy text. Enter with Prefix [. Supports both emacs and vi key sets: the default is emacs unless $EDITOR or $VISUAL contains “vi”. The table below lists tmux's built-in defaults; the setup block remaps v and y so selection works like Vim.

bash — copy mode setup

# Enable vi keys in copy mode (.tmux.conf)

setw -g mode-keys vi


# Bind vi-style copy (add to .tmux.conf)

bind-key -T copy-mode-vi v send-keys -X begin-selection

bind-key -T copy-mode-vi y send-keys -X copy-selection-and-cancel

bind-key -T copy-mode-vi Escape send-keys -X cancel


# Enter copy mode from command line

$ tmux copy-mode

# Paste buffer

$ tmux paste-buffer

# List buffers

$ tmux list-buffers

# Save buffer to file

$ tmux save-buffer ~/clipboard.txt

Key (vi mode)Key (emacs mode)Action
Prefix [Prefix [Enter copy mode
qq / EscExit copy mode
EscCtrl-gClear selection
h j k l← ↓ ↑ →Move cursor
0 / $ / ^Ctrl-a / Ctrl-e / Alt-mLine start / end / indentation
/Ctrl-sSearch forward
?Ctrl-rSearch backward
n / Nn / NNext / previous search match
SpaceCtrl-SpaceStart selection
vRToggle rectangle selection
V—Select whole line
EnterAlt-wCopy selection and exit
g / GAlt-< / Alt->Jump to top / bottom of history
Ctrl-u / Ctrl-dAlt-↑ / Alt-↓Scroll half page up / down
Ctrl-b / Ctrl-fAlt-v / Ctrl-vScroll full page up / down
:—Go to line
Prefix ]Prefix ]Paste from buffer

Server & Miscellaneous Commands

Commands to inspect and control the tmux server, display information, and manage options at runtime.

bash — server & misc

# Server information

$ tmux info # detailed server info

$ tmux -V # print tmux version


# Config

$ tmux source-file ~/.tmux.conf # reload config

$ tmux show-options -g # show all global options

$ tmux show-options -g | grep prefix # filter options

$ tmux set-option -g mouse on # set option at runtime


# Display

$ tmux display-message "Hello!" # show message in status bar

$ tmux display-message -p "#{session_name}" # print variable value


# List commands & keys

$ tmux list-commands # all available commands

$ tmux list-keys # all key bindings

$ tmux run-shell "echo test" # run shell command

Scripting Commands

Automate tmux sessions, send keystrokes to panes, and conditionally run commands from shell scripts.

bash — scripting & automation

# send-keys: run commands in a pane without focusing it

$ tmux send-keys -t dev:0 "npm run dev" Enter

$ tmux send-keys -t dev:0.1 "nvim ." Enter # target pane :window.pane


# send-prefix: send prefix key to a pane (for nested tmux)

$ tmux send-prefix -t dev:0


# has-session: check before attaching (useful in .bashrc)

$ tmux has-session -t dev 2>/dev/null && tmux attach -t dev || tmux new -s dev


# if-shell: conditional execution based on shell output

$ tmux if-shell "[ $(tmux -V | cut -c6) -gt 2 ]" "set -g mouse on"


# run-shell: run a command in the background

$ tmux run-shell "git pull origin main"


# Full session setup script example

$ tmux new-session -d -s dev -c ~/projects/myapp

$ tmux rename-window -t dev:0 'editor'

$ tmux send-keys -t dev:0 'nvim .' Enter

$ tmux split-window -h -t dev:0

$ tmux send-keys -t dev:0 'npm run dev' Enter

$ tmux new-window -t dev -n 'server'

$ tmux attach -t dev

Target Specification Syntax & CLI Scripting Primitives

When automating tmux via bash scripts, CI/CD pipelines, or external CLI tools, the -t target flag enables surgical control down to individual panes.

Target Spec Breakdown

Format: [session]:[window].[pane]

  • -t mysession — Target entire session
  • -t mysession:1 — Target window index 1
  • -t mysession:1.0 — Target pane index 0 in window 1
  • -t :+ / -t :- — Target next / previous window
  • -t .{top-right} — Target pane by geographical corner

Programmatic Buffer Scraping

Extract live terminal text directly into shell scripts or LLM analysis tools using capture-pane:

# Dump last 500 lines of pane output to stdout
tmux capture-pane -p -S -500 -t dev:0.0

# Extract compile error lines
tmux capture-pane -p -t dev:0.1 | grep -i "error"

Literal String Injection

Send strings containing quotes, slashes, or special symbols without shell expansion:

# -l sends keys literally (no meta interpretation)
tmux send-keys -l -t dev:0 'echo "$PWD && ls -la"'
tmux send-keys -t dev:0 Enter

Need a quick scannable reference?

The /cheat-sheet/ is a printable visual grid of every key binding — perfect to print and keep by your terminal.

View Cheat Sheet → Session Management →