🖥️ tmux Command Cheat Sheet

The **Prefix Key** is the core of tmux. By default, it is Ctrl+b.
You must press and release the Prefix Key *before* pressing the Command Key for internal commands.

🛠️ Installation & Session Management

These commands are run directly in your shell (outside of a tmux session).

Command Action Copy Command
sudo apt install tmux (Ubuntu/Debian) Install tmux on your system.
tmux **Start a New Session** (usually named 0, 1, 2, etc.) and attach to it.
tmux new -s my_project Start a New Session and give it a specific name.
tmux ls List all currently running sessions.
tmux attach -t 0 **Re-attach** to session with ID 0. (Use name for named sessions).
tmux kill-session -t 0 Stop and remove a running session by ID.

🚪 Session Commands (Inside tmux)

Run these while inside a tmux session using the **Prefix Key** (Ctrl+b).

Prefix + Key Action Description
Ctrl+b then d **Detach Session** Disconnects your client, leaving the session running in the background.
Ctrl+b then s **List Sessions** Shows a list of all active sessions to switch between.
Ctrl+b then ? Help Shows a list of all keybindings (shortcuts).

💻 Pane Commands (Splitting)

Panes split a single window into multiple sections.

Prefix + Key Action Description
Ctrl+b then % **Split Vertically** Splits the current pane into two side-by-side.
Ctrl+b then " **Split Horizontally** Splits the current pane into two top-and-bottom.
Ctrl+b then x **Close Pane** Kills the current pane (asks for confirmation).

↔️ Pane Navigation & Focus

Prefix + Key Action Description
Ctrl+b then ←/↑/→/↓ **Navigate** Moves the cursor focus to the adjacent pane.
Ctrl+b then z **Zoom** Maximizes the current pane to fill the entire window. Press again to un-zoom.
Ctrl+b then o **Cycle** Moves to the next pane in the sequence.
Ctrl+b then space **Toggle Layout** Cycles through pre-defined pane arrangements.

📁 Window Commands (Like Tabs)

Windows are full-screen terminals within a session.

Prefix + Key Action Description
Ctrl+b then c **New Window** Creates a new, empty window.
Ctrl+b then n **Next Window** Switches to the next window.
Ctrl+b then p **Previous Window** Switches to the previous window.
Ctrl+b then 0-9 **Specific Window** Switches directly to the window number (0 is the first).
Ctrl+b then , **Rename Window** Prompts you to enter a new name for the current window.

📜 Scrollback Mode (Copy Mode)

Use this to scroll up and copy text, similar to using the mouse scroll wheel.

Prefix + Key Action Description
Ctrl+b then [ **Enter Copy Mode** Allows you to scroll up using the arrow keys (or Vim/Emacs keys).
q or Esc **Exit Copy Mode** Exits scrollback/copy mode.