Tmux Cheat Sheet
Master tmux with a comprehensive cheat sheet.

Tmux is a terminal multiplexer that helps you manage multiple tasks and workflows.
With tmux, you can:
- Sessions: Preserve your work and keep tasks running, even if you log out or disconnect.
- Windows: Create separate workspaces for different projects or tools within the same session.
- Panes: Split a window into multiple views so you can monitor and interact with several processes side by side.

Installing tmux
Linux: Often pre-installed.
macOS: Install it using Homebrew.
brew install tmuxWindows: Install via WSL (Windows Subsystem for Linux).
sudo apt update
sudo apt install tmuxStarting and exiting tmux sessions
Start a default session:
tmuxStart a named session:
tmux new -s <session-name>Detach from a session:
Leave the current tmux session running in the background so you can come back to it later.
Ctrl-b dExit a session:
Close tmux completely. This will terminate the application and end all running sessions.
Ctrl-dManaging tmux sessions
List sessions:
tmux list-sessions
tmux lsAttach to a session:
tmux attach -t <session-name>
tmux a -t <session-name>Kill a session:
tmux kill-session -t <session-name>Kill all sessions:
tmux kill-serverTmux sessions
Rename current session:
Ctrl-b $Choose a session from a list:
Ctrl-b sClose a session:
Ctrl-dTmux windows
Create a new window:
Ctrl-b cRename a window:
Ctrl-b ,Move to next / previous window:
Ctrl-b n
Ctrl-b pGo to a specific window:
Ctrl-b 0
Ctrl-b ...
Ctrl-b 9List windows:
Ctrl-b wClose window:
Ctrl-b &Tmux panes
Split vertically:
Ctrl-b %Split horizontally:
Ctrl-b "Move between panes:
Ctrl-b ← ↓ ↑ →Resize a pane:
Ctrl-b hold Ctrl ← ↓ ↑ →Resize a pane (macOS only):
Ctrl-b hold Shift + Option ← ↓ ↑ →Maximize/minimize a pane:
Ctrl-b zChange layout:
Ctrl-b SpaceClose a pane:
Ctrl-dSearching in tmux
You can search through your tmux history using copy mode. This allows you to scroll back and find specific text in the buffer.
1. Enter tmux copy mode:
Ctrl-b [2. Start a search:
Search downwards:
Ctrl-sSearch upwards:
Ctrl-r3. Navigate through matches:
Type your search term and press Enter.
Press n to jump to the next occurrence.
Press N to jump to the previous occurrence.
4. Exit copy mode:
Press q or Escape twice to exit copy mode.
Searching for a window in tmux
When you have multiple windows open, you can quickly jump to one based on text currently displayed inside it.
1. Open the find-window prompt:
Ctrl-b f2. Type your search term:
Type the text you are looking for, then press Enter.
3. Select the matching window:
If there's only one match, tmux will switch to it automatically.
If multiple windows match, you'll see a list and can choose the one you want.