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 documents every command with all flags, use cases, and copy-ready examples.

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 nameCreate a new named session
list-sessionslsList all sessions
attach-session -t nameattach -t nameAttach to a named session
detach-clientPrefix dDetach from current session
rename-session -t old newPrefix $Rename a session
kill-session -t nameKill a specific session
kill-serverKill tmux server and all sessions
has-session -t nameCheck if session exists (returns 0/1)
switch-client -t namePrefix sSwitch to another session interactively
switch-client -pPrefix (Switch to previous session
switch-client -nPrefix )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
list-windowsPrefix wShow window chooser
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 MSwap position of two windows
move-window -rRenumber 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 -p 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)

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 (hold and repeat)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

Copy Mode Commands

Copy mode lets you scroll through pane history, search, and copy text. Enter with Prefix [. Supports both emacs (default) and vi key sets.

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
q / EscqExit copy mode
h j k l← ↓ ↑ →Move cursor
0 / $ / ^Ctrl-a / Ctrl-eLine start / end / indentation
/Ctrl-sSearch forward
?Ctrl-rSearch backward
n / Nn / NNext / previous search match
vSpaceStart selection
VStart line selection
yEnterCopy selection and exit
g / GAlt-< / Alt->Jump to top / bottom
Ctrl-u / Ctrl-dAlt-v / Ctrl-vScroll half page up / down
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

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 →