tmux // cheatsheet

for SSH sessions on Pi & Jellyfin server

Prefix key: Ctrl + b โ€” press it, release, then press the command key.
All shortcuts below assume the default prefix.
๐Ÿ“ฆ Sessions
New named session
$tmux new -s mysession
Attach to last session
$tmux attach
Attach to named session
$tmux attach -t mysession
List sessions
$tmux ls
Kill a session
$tmux kill-session -t mysession
Attach or create (alias trick)
$tmux attach || tmux new
Detach from session
prefix+d
Rename current session
prefix+$
Switch to session by name
prefix+s
๐ŸชŸ Windows (tabs)
New window
prefix+c
Next window
prefix+n
Previous window
prefix+p
Go to window by number
prefix+0โ€“9
Rename current window
prefix+,
List windows
prefix+w
Close current window
prefix+&
โฌ› Panes (splits)
Split horizontally (top/bottom)
prefix+"
Split vertically (left/right)
prefix+%
Navigate panes
prefix+โ†‘โ†“โ†โ†’
Cycle through panes
prefix+o
Close current pane
prefix+x
Zoom pane (toggle fullscreen)
prefix+z
Resize pane
prefix+Ctrl+โ†‘โ†“โ†โ†’
Show pane numbers
prefix+q
๐Ÿ“‹ Copy Mode (scrollback)
Enter copy mode (scroll up)
prefix+[
Exit copy mode
q
Scroll up / down
โ†‘โ†“orPgUp/Dn
Start selection
Space
Copy selection
Enter
Paste buffer
prefix+]
Search backward
?thenEnter
โš™๏ธ Misc & Useful
Show key bindings
prefix+?
Command prompt
prefix+:
Reload config
prefix+:โ†’source ~/.tmux.conf
Show time
prefix+t
Move pane to new window
prefix+!
Swap pane with previous
prefix+{
Swap pane with next
prefix+}
๐Ÿ”Œ Your SSH Workflow
SSH + attach or create session in one command
$ssh pi@192.168.x.x -t "tmux attach || tmux new"
Put in ~/.zshrc as alias
$alias sshpi='ssh pi@x.x -t "tmux attach || tmux new"'
Run update, safe to close laptop
$sudo apt upgrade # inside tmux
Detach and close laptop safely
prefix + d, then close lid
Come back later, reattach
$tmux attach