Skip to content

Instantly share code, notes, and snippets.

@ibnsamy96
Last active August 7, 2026 00:34
Show Gist options
  • Select an option

  • Save ibnsamy96/707d8926f02691c30027eb04c93f66ab to your computer and use it in GitHub Desktop.

Select an option

Save ibnsamy96/707d8926f02691c30027eb04c93f66ab to your computer and use it in GitHub Desktop.

tmux Cheat Sheet

Prefix key is Ctrl+b by default — press it, release, then press the next key.

Sessions

Command Action
tmux Start new session
tmux new -s name Start named session
tmux ls List sessions
tmux attach -t name Attach to session
tmux kill-session -t name Kill session
Ctrl+b d Detach from session

Windows (tabs)

Shortcut Action
Ctrl+b c Create new window
Ctrl+b , Rename window
Ctrl+b n Next window
Ctrl+b p Previous window
Ctrl+b 0-9 Jump to window number
Ctrl+b w List windows
Ctrl+b & Kill window

Panes (splits)

Shortcut Action
Ctrl+b % Split vertically (side by side)
Ctrl+b " Split horizontally (top/bottom)
Ctrl+b arrow key Move between panes
Ctrl+b o Cycle to next pane
Ctrl+b z Zoom/unzoom current pane
Ctrl+b x Kill current pane
Ctrl+b space Cycle pane layouts
Hold Ctrl+b + arrow Resize pane

Copy mode (scroll/select)

Shortcut Action
Ctrl+b [ Enter copy mode (scroll with arrows)
q Quit copy mode
space Start selection (in copy mode)
Enter Copy selection
Ctrl+b ] Paste

Detaching and Attaching

Detaching = leaving a tmux session running in the background while you step away from it, without closing it. Your programs (servers, SSH connections, editors, etc.) keep running exactly as they were.

Press Ctrl+b d to detach. You're back at your normal terminal, but the session is still alive on the machine.

Attaching = reconnecting to that still-running session and picking up right where you left off — same panes, same windows, same running processes.

Run tmux attach -t name (or tmux a -t name) to attach.

Why it matters: the big use case is SSH. Say you're SSH'd into a remote server and running a long build or a script inside tmux. If your connection drops or you close your laptop, a normal terminal session would kill that process. But if it's inside tmux, you just detach (or even lose connection accidentally), and when you SSH back in later, you tmux attach and the process is still running like nothing happened.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment