Tmux Cheat Sheet

Master tmux with a comprehensive cheat sheet.

Cupola window by Karen Nyberg

Tmux

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.
macOS Terminal + Starship + Tmux

Installing tmux

Linux: Often pre-installed.

macOS: Install it using Homebrew.

brew install tmux

Windows: Install via WSL (Windows Subsystem for Linux).

sudo apt update
sudo apt install tmux

Starting and exiting tmux sessions

Start a default session:

tmux

Start 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   d

Exit a session:

Close tmux completely. This will terminate the application and end all running sessions.

Ctrl-d

Managing tmux sessions

List sessions:

tmux list-sessions
tmux ls

Attach 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-server

Tmux sessions

Rename current session:

Ctrl-b   $

Choose a session from a list:

Ctrl-b   s

Close a session:

Ctrl-d

Tmux windows

Create a new window:

Ctrl-b   c

Rename a window:

Ctrl-b   ,

Move to next / previous window:

Ctrl-b   n
Ctrl-b   p

Go to a specific window:

Ctrl-b   0
Ctrl-b   ...
Ctrl-b   9

List windows:

Ctrl-b   w

Close 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   z

Change layout:

Ctrl-b   Space

Close a pane:

Ctrl-d

Searching 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   [

Search downwards:

Ctrl-s

Search upwards:

Ctrl-r

3. 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   f

2. 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.