Skip to content

Tmux Cheat Sheet

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

Terminal + Starship + Tmux

  • Linux: often pre-installed.

  • macOS:

    Terminal window
    brew install tmux
  • Windows: Use via WSL (Windows Subsystem for Linux)

    Terminal window
    sudo apt update
    sudo apt install tmux

Start a default session:

Terminal window
tmux

Start a named session:

Terminal window
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

List sessions:

Terminal window
tmux list-sessions
tmux ls

Attach to a session:

Terminal window
tmux attach -t <session-name>
tmux a -t <session-name>

Kill a session:

Terminal window
tmux kill-session -t <session-name>

Kill all sessions:

Terminal window
tmux kill-server

Rename current session:

Ctrl-b $

Choose a session from a list:

Ctrl-b s

Close a session:

Ctrl-d

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 &

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

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-s

    Search upwards:

    Ctrl-r
  3. Type your search term and press Enter.

  4. Navigate through matches:

    • Press n to jump to the next occurrence.
    • Press N to jump to the previous occurrence.
  5. Exit copy mode:

    Press q or Escape twice to exit copy mode.**

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.