tmux

Structure

tmux server
 └── session
      └── window
           └── pane

Component

Description

Server

The tmux background process.

Session

A workspace (collection of windows).

Window

A tab inside a session.

Pane

A split terminal inside a window.

Commands

Session Commands

Command
Description

tmux

Start tmux

tmux new

Create a new session

tmux new -s name

Create a named session

tmux new-session -d -s <session_name> "command"

Create a session for only specific command execution

tmux ls

List sessions

tmux attach

Attach to last session

tmux attach -t name

Attach to named session

tmux detach

Detach current client

tmux kill-session -t name

Kill a session

tmux kill-server

Kill all tmux sessions

Window Commands

Command
Description

tmux new-window

Create new window

tmux new-window -n name

Create named window

tmux list-windows

List windows

tmux rename-window name

Rename current window

tmux select-window -t 1

Switch to window 1

tmux kill-window

Kill current window

Pane Commands

Command
Description

tmux split-window -h

Split pane horizontally

tmux split-window -v

Split pane vertically

tmux list-panes

List panes

tmux select-pane -L

Move to left pane

tmux select-pane -R

Move to right pane

tmux select-pane -U

Move to upper pane

tmux select-pane -D

Move to lower pane

tmux kill-pane

Kill current pane

Targeting (session:window.pane)

Example
Meaning

session

Target session

session:1

Window 1 in session

session:1.0

Pane 0 in window 1

-t dev:2.1

Target pane 1, window 2, session dev

Config & Options

Command
Description

tmux show-options -g

Show global options

tmux set-option -g mouse on

Enable mouse support

tmux source-file ~/.tmux.conf

Reload config

tmux list-keys

List key bindings

tmux list-commands

List all tmux commands

Automation / Scripting

Command
Description

tmux send-keys "cmd" C-m

Send command cmd to pane (C-m is carriage return)

tmux has-session -t name

Check if session exists

tmux display-message

Show tmux message

Common control keys

Key
Meaning
Typical use

C-m

Enter / Carriage Return

Execute command

C-c

Ctrl-C

Stop current process

C-d

EOF

Exit shell / close SSH

C-z

Suspend

Background process

C-l

Clear screen

Clean output

C-u

Kill line

Clear current input

C-w

Delete word

Edit input

C-a

Start of line

Bash readline

C-e

End of line

Bash readline

C-r

Reverse search

History search

C-p

Previous command

History up

C-n

Next command

History down

C-s

Forward search

(may need stty -ixon)

Meta/Alt keys

Key
Meaning

M-b

Back one word

M-f

Forward one word

M-d

Delete word

M-.

Last argument of previous command

M-Enter

Literal newline (app-dependent)

Shortcuts inside tmux

Basics

Action
Shortcut

Prefix

Ctrl + b

Help (list shortcuts)

Ctrl + b?

Reload config

Ctrl + b:source-file ~/.tmux.conf

Windows (tabs)

Action
Shortcut

New window

Ctrl + bc

Next window

Ctrl + bn

Previous window

Ctrl + bp

Switch by number

Ctrl + b0–9

Rename window

Ctrl + b,

Close window

Ctrl + b&

Panes (splits)

Action
Shortcut

Vertical split

Ctrl + b%

Horizontal split

Ctrl + b"

Switch panes

Ctrl + b → Arrow keys

Close pane

Ctrl + bx

Zoom pane (toggle)

Ctrl + bz

Resize pane

Ctrl + bCtrl + Arrow

Sessions

Action
Shortcut / Command

Detach session

Ctrl + bd

Sessions navigation view

Ctrl + bs

Copy / Scroll Mode

Action
Shortcut

Enter copy mode

Ctrl + b[

Enter copy mode

Ctrl + b → Page Up

Scroll

Arrow keys / Page Up

Exit copy mode

Ctrl + bq

Paste

Ctrl + b]

Power-user favorites

Action
Shortcut

Last window

Ctrl + bl

Swap panes

Ctrl + b{ or }

Show clock

Ctrl + bt

Last updated