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.
# 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"
| Command | Alias / Short | Key Binding | Description |
|---|---|---|---|
new-session -s name | new -s name | — | Create a new named session |
list-sessions | ls | — | List all sessions |
attach-session -t name | attach -t name | — | Attach to a named session |
detach-client | — | Prefix d | Detach 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 name | — | Prefix s | Switch to another session interactively |
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.
$ 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
| Command | Key Binding | Description |
|---|---|---|
new-window -n name | Prefix c | Create new window (with optional name) |
rename-window name | Prefix , | Rename current window |
select-window -t :N | Prefix 0-9 | Select window by number |
next-window | Prefix n | Move to next window |
previous-window | Prefix p | Move to previous window |
last-window | Prefix l | Toggle between last two windows |
list-windows | Prefix w | Show window chooser |
find-window -N name | Prefix f | Search windows by name |
kill-window -t :N | Prefix & | Kill a window and all its panes |
move-window -t session:N | Prefix . | 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.
# 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 ?.
| Binding | Action | Category |
|---|---|---|
| Prefix c | Create new window | Windows |
| Prefix n / p | Next / Previous window | Windows |
| Prefix l | Last (toggled) window | Windows |
| Prefix 0–9 | Select window by number | Windows |
| Prefix w | Interactive window chooser | Windows |
| Prefix , | Rename current window | Windows |
| Prefix & | Kill current window | Windows |
| Prefix % | Split pane horizontally | Panes |
| Prefix " | Split pane vertically | Panes |
| Prefix ↑↓←→ | Navigate between panes | Panes |
| Prefix o | Select next pane | Panes |
| Prefix z | Toggle pane zoom (fullscreen) | Panes |
| Prefix x | Kill current pane | Panes |
| Prefix q | Show pane numbers | Panes |
| Prefix { / } | Swap pane backward / forward | Panes |
| Prefix ! | Break pane into new window | Panes |
| Prefix Space | Cycle through pane layouts | Panes |
| Prefix Ctrl+↑↓←→ | Resize pane (hold and repeat) | Panes |
| Prefix d | Detach from session | Sessions |
| Prefix s | Interactive session chooser | Sessions |
| Prefix $ | Rename current session | Sessions |
| Prefix [ | Enter copy mode | Copy |
| Prefix ] | Paste from buffer | Copy |
| Prefix = | Choose paste buffer from list | Copy |
| Prefix : | Open command-line prompt | Misc |
| Prefix ? | List all key bindings | Misc |
| Prefix t | Show clock in current pane | Misc |
| Prefix D | Choose client to detach | Misc |
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.
# 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 / Esc | q | Exit copy mode |
| h j k l | ← ↓ ↑ → | Move cursor |
| 0 / $ / ^ | Ctrl-a / Ctrl-e | Line start / end / indentation |
| / | Ctrl-s | Search forward |
| ? | Ctrl-r | Search backward |
| n / N | n / N | Next / previous search match |
| v | Space | Start selection |
| V | — | Start line selection |
| y | Enter | Copy selection and exit |
| g / G | Alt-< / Alt-> | Jump to top / bottom |
| Ctrl-u / Ctrl-d | Alt-v / Ctrl-v | Scroll 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.
# 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.
# 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.