learntmux.dev

Change the prefix key

Goal

The prefix is C-a, C-b is unbound, and a window was opened with C-a c.

Moving the prefix takes three lines, and each one does a different job:

set -g prefix C-a
tell tmux which key to wait for
unbind C-b
drop the old key’s now-stale binding
bind C-a send-prefix
so pressing C-a twice still sends a real C-a through

One line is not enough because the prefix option only changes which key tmux watches. It does not move the send-prefix binding, which was attached to C-b itself.

That third line earns its place here: C-a is the shell’s beginning-of-line key, so without an escape hatch you lose it.

Do this

Run open ~/.tmux.conf, add these lines, and save with Ctrl-S:

set -g prefix C-a
unbind C-b
bind C-a send-prefix

Press C-b : one last time, type source ~/.tmux.conf, Enter.

Nothing visible changes — but C-b is now inert.

Press C-a c.

A second window opens: the list reads 0:shell- 1:sh*.

What makes the prefix special

The prefix is an ordinary key with one job: read the next key and look it up in the prefix table. Nothing else about it is special.

Stuck on this one?

This is a live terminal. Typing goes to the machine, including Tab. Press Shift and Tab together to move focus back out to the page.

A real terminal, in this tab

about 15 MB, once

session learn

Done when

not started
  1. The prefix option is set to C-a— not done yet
  2. C-a is bound in the prefix table to send-prefix— not done yet
  3. C-b is no longer bound in the prefix table— not done yet
  4. A second window exists in session learn, opened with the new prefix— not done yet