TMUX COMMAND REFERENCE

Mac Terminal  /  SSH  /  Session Persistence

Default Prefix
Ctrl-y
Press prefix, then key.
+
← klicken, dann Taste drücken
Ergebnis: Ctrl-y Shift als Prefix wird von
den meisten Terminals nicht unterstützt.
🚀 Quick Start
1
SSH to your server
ssh user@server
2
Start a new session
tmux new -s mysession
3
Do your work Split panes, run tasks, tail logs…
4
Detach (leave session running)
Ctrl-y d
5
Reattach later
tmux attach -t mysession
TIP (Mac): Install tmux via Homebrew: brew install tmux
Session Management (CLI)
CommandDescription
tmux new -s <name>Create new session with name
tmux new -s <name> -dCreate new session (detached)
tmux lsList sessions
tmux a -t <name>Attach to session
tmux attach -t <name>Attach (same as above)
tmux aAttach to last session
tmux kill-session -t <name>Kill session by name
tmux kill-serverKill all sessions (careful!)
tmux rename-session <new>Rename current session
tmux switch -t <name>Switch client to session
tmux list-sessionsAlias of tmux ls
TIP: Use descriptive session names per project or task.
🔗 Attach / Detach
Inside tmux
ShortcutAction
Ctrl-y dDetach (session keeps running)
From Shell
CommandDescription
tmux attach -t <name>Attach to named session
tmux a -t <name>Attach (short form)
tmux aAttach to last session
Why detach?
Your processes keep running even after closing the SSH connection.
🖥 Windows (Tabs)
ShortcutAction
Ctrl-y cCreate new window
Ctrl-y nNext window
Ctrl-y pPrevious window
Ctrl-y 0–9Go to window by number
Ctrl-y ,Rename current window
Ctrl-y wList windows (choose)
Ctrl-y &Close current window
Windows are like tabs. Keep related workloads separate.
Panes (Splits)
ShortcutAction
Ctrl-y %Split pane vertically
Ctrl-y "Split pane horizontally
Ctrl-y oNext pane
Ctrl-y ;Previous pane
Ctrl-y {Swap pane with previous
Ctrl-y xClose current pane
Ctrl-y !Break pane to new window
Ctrl-y zToggle pane zoom (max/min)
Pane zoom is great for focusing on one task.
Navigation & Misc
ShortcutAction
Ctrl-y ← ↑ ↓ →Move between panes
Ctrl-y qShow pane numbers
Ctrl-y tShow clock
Ctrl-y SpaceCycle layouts
Ctrl-y ?List all key bindings
Ctrl-y :Command prompt
Ctrl-y ~Show previous messages
Use Ctrl-y : to run any tmux command.
📋 Copy Mode (Scroll & Copy)
ShortcutAction
Ctrl-y [Enter copy mode
Space / EnterStart selection
↑ ↓ ← →Move cursor
PgUp / PgDnScroll up/down
Ctrl-y ]Paste buffer
q / EscExit copy mode
Copy mode works like less. Scroll, select, copy, then paste with Ctrl-y ].
🔍 Search
ShortcutAction
Ctrl-y /Search forward
Ctrl-y ?Search backward
nNext match
NPrevious match
EnterJump to match
q / EscExit search
Search happens in copy mode. Use / or ? to find text in the scrollback.
Resizing
Shortcut / CommandAction
Ctrl-y :Enter command prompt
resize-pane -L 10Shrink pane left by 10
resize-pane -R 10Shrink pane right by 10
resize-pane -U 5Shrink pane up by 5
resize-pane -D 5Shrink pane down by 5
Ctrl-y ← ↑ ↓ →Resize pane (1 cell)
Ctrl-y Alt+← ↑ ↓ →Resize pane (5 cells)
Hold Option (Alt) on Mac for bigger steps.
Config Reloading
CommandDescription
Ctrl-y :Open command prompt
source-file ~/.tmux.confReload config file
show-options -gShow global options
show-optionsShow current options
display-message "ok"Test command execution
After editing ~/.tmux.conf run:
Ctrl-y : source-file ~/.tmux.conf
Useful tmux CLI Commands
CommandDescription
tmux list-panesList panes in session
tmux list-windowsList windows
tmux list-clientsList attached clients
tmux infoShow tmux info
tmux show-bufferShow paste buffer
tmux save-buffer -b <file>Save buffer to file
tmux show-historyShow command history
tmux capture-pane -pPrint pane content
tmux pipe-pane -o 'cat >> out.log'Pipe pane output to cmd
Combine tmux with scripts and logs for automation.
🛡 SSH Survival Workflow
1
Start tmux right after SSH.
tmux new -s work
2
Run long tasks inside tmux panes.
docker logs -f …   make build …
3
Detach before disconnecting.
Ctrl-y d
4
Disconnect SSH (Wi-Fi drop, laptop sleep, etc.)
5
Reconnect & reattach later.
tmux a -t work
6
Your processes are still running!
tmux = your safety net for remote work.
Workflow at a Glance
💻
SSH to Server
ssh user@server
Start tmux
tmux new -s work
Do Your Work
split, run, monitor
Detach
Ctrl-y   d
Disconnect Safely
close terminal / drop
💻
Reconnect Later
ssh user@server
🔗
Reattach
tmux a -t work