Learn tmux

Terminal multiplexer: persistent sessions, windows and split panes

13 lessons · 2 hours · 4 levels · covers tmux 3.5

tmux runs many shells inside one terminal, split into windows and panes, inside sessions that keep running after you disconnect. It is the standard way to keep long jobs alive on remote servers and to build a keyboard-driven terminal workspace.

Before you start

tmux builds on these; the tree links to the exact lessons you need.

How deep do you want to go?

1. EssentialsRead and write simple code, do the everyday basics4 lessons · 31 min in total
2. PracticalUse it productively at work, with the usual idioms7 lessons · 1 hour in total
3. AdvancedThe less common features, performance and trade-offs10 lessons · 2 hours in total
4. ExpertInternals and the edge cases experts know13 lessons · 2 hours in total

The tmux tree

tmuxThe prefix key and command promptThe prefix key andcommand promptSessions: create, detach, attachSessions: create,detach, attachWindows: tabs inside a sessionWindows: tabs insidea sessionPanes: splitting the screenPanes: splitting thescreenCopy mode: scrollback, search and copyCopy mode:scrollback, search…~/.tmux.conf: options and bindings~/.tmux.conf: optionsand bindingsWorking with many sessionsWorking with manysessions
Essentials and Practical shown (7 of 13 lessons); the full list is below. Click a lesson to read it.

All 13 lessons, in order

Getting started

  1. The prefix key and command prompt · Essentials · 6 min

    Every tmux shortcut starts with the prefix Ctrl-b; Ctrl-b ? lists all keys and Ctrl-b : opens the command prompt.

  2. Sessions: create, detach, attach · Essentials · 8 min

    A session is a set of windows owned by the tmux server; you can detach from it and reattach later, even from another login.

  3. Working with many sessions · Practical · 9 min

    Run one session per project, switch between them from inside tmux, and use tmux on remote machines over SSH.

Windows and panes

  1. Windows: tabs inside a session · Essentials · 7 min

    Each session holds numbered windows, like terminal tabs: create with C-b c, switch with C-b n, p or a number.

  2. Panes: splitting the screen · Essentials · 10 min

    Split a window into panes with C-b % and C-b ", move between them, zoom one with C-b z and cycle layouts.

Copy mode and clipboard

  1. Copy mode: scrollback, search and copy · Practical · 10 min

    Enter copy mode to scroll back through output, search it, select text and paste it into another pane.

  2. System clipboard integration · Advanced · 10 min

    Send tmux copies to the system clipboard with set-clipboard (OSC 52) or copy-pipe, locally and over SSH.

Configuration

  1. ~/.tmux.conf: options and bindings · Practical · 12 min

    Customise tmux with set and bind in ~/.tmux.conf: change the prefix, enable the mouse, number from 1 and split in the current directory.

Scripting and automation

  1. Scripting layouts with send-keys · Advanced · 12 min

    Drive tmux from shell scripts: create detached sessions, split panes, start programs with send-keys, then attach.

  2. Formats: #{...} variables and conditionals · Advanced · 12 min

    Query and display tmux state with formats like #{session_name} and #{pane_current_path}, in scripts and in the status line.

Internals

  1. Server, sockets, clients and groups · Expert · 12 min

    Understand the tmux server process, its Unix socket, multiple clients, grouped sessions and the environment it captures.

  2. Hooks, pipe-pane, wait-for and control mode · Expert · 12 min

    React to tmux events with hooks, log pane output with pipe-pane, synchronise scripts with wait-for and integrate via control mode.

  3. TERM, colours, keys and escape-time · Expert · 12 min

    tmux is itself a terminal emulator: set TERM correctly, enable true colour and extended keys, and tune escape-time.