Tmux Command Reference: Master Your Terminal Sessions

Classified in Technology

Written on in English with a size of 7.51 KB

Tmux Commands Reference

Introduction to Tmux

Tmux (Terminal Multiplexer) is a powerful terminal multiplexer for Unix-like operating systems. It allows you to manage multiple terminal sessions from a single window, enhancing your command-line productivity.

Basic Tmux Commands

DescriptionCommand
Start a new session
$ tmux
Start a new named session
$ tmux new -s myname
Show all sessions
$ tmux ls
Attach to the last session
$ tmux a
Attach to a named session
$ tmux a -t myname
Kill a session by name
$ tmux kill-ses -t myname
Kill all sessions except the current
$ tmux kill-ses -a
Kill all sessions except 'myname'
$ tmux kill-ses -a -t myname
Reload Tmux configuration
$ tmux source-file ~/.tmux.conf
Show global Tmux options
$ tmux show-options -g
Display Tmux server information
$ tmux info

Tmux Copy Mode

Copy mode in Tmux allows you to select and copy text from your terminal buffer. It mainly works like selecting text in Vim.

ShortcutDescription
Ctrl+b [Enter copy mode
SpaceStart selection
EnterCopy selection
qQuit copy mode
Ctrl+b ]Paste contents of buffer_0

Essential Tmux Shortcuts

Getting Started with Shortcuts

ShortcutDescription
Ctrl+b ?List all shortcuts

Panes (Splits)

ShortcutDescription
Ctrl+b " / %Split Horizontally / Vertically
Ctrl+b !Move pane to a new window
Ctrl+b xKill current pane
Ctrl+b <Arrow>Navigate panes
Ctrl+b SpaceToggle pane layouts
Ctrl+b { / }Move current pane Left / Right
Ctrl+b oGo to next pane
Ctrl+b zToggle full-screen for current pane
Ctrl+b ;Toggle to last active pane
Ctrl+b qShow pane numbers
Ctrl+b q 0...9Go to pane number

Windows (Tabs)

ShortcutDescription
Ctrl+b cCreate new window
Ctrl+b p / nPrevious / Next window
Ctrl+b " / %Split Horizontally / Vertically (within window)
Ctrl+b wList all windows
Ctrl+b ,Rename current window
Ctrl+b fFind window by name
Ctrl+b lGo to last active window
Ctrl+b .Move current window
Ctrl+b &Close current window
Ctrl+b 0...9Go to window number

Sessions (Set of Windows)

ShortcutDescription
Ctrl+b dDetach from current session
Ctrl+b sShow all sessions
Ctrl+b $Rename current session
Ctrl+b ( / )Previous / Next session

Tmux Command Mode

Enter command mode by pressing Ctrl+b :. This allows you to type Tmux commands directly.

Command Mode Usage

ShortcutDescription
Ctrl+b :Enter command mode

Resizing Panes (Command Mode)

CommandDescription
resize-pane -D 20Resize pane down by 20 units
resize-pane -U 20Resize pane up by 20 units
resize-pane -L 20Resize pane left by 20 units
resize-pane -R 20Resize pane right by 20 units

Listing Information (Command Mode)

CommandDescription
list-keysList all key bindings
list-panesList all panes
list-windowsList all windows

Copying and Buffers (Command Mode)

CommandDescription
list-buffersList all paste buffers
show-bufferShow contents of buffer #0
capture-paneCopy current pane's content to buffer
choose-bufferShow and paste from selected buffer
save-buffer a.txtSave buffer contents to a file
delete-buffer -b 1Delete buffer number 1

Setting Options (Command Mode)

CommandDescription
set -g OPTIONSet global option for all sessions
setw -g OPTIONSet global option for all windows
setw -g mode-keys viEnable vi-mode for copy mode
set -g prefix C-aSet prefix key to Ctrl+a

Miscellaneous Commands

CommandDescription
swap-pane -s 3 -t 1Swap pane 3 with pane 1
swap-window -t -1Move current window to the left
setw synchronize-panesToggle synchronized input across panes
join-pane -t :#Join pane to target window/pane

Related entries: