Change the prefix key
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-atwice still sends a realC-athrough
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.
Run open ~/.tmux.conf, add these lines, and save with Ctrl-S:
set -g prefix C-a
unbind C-b
bind C-a send-prefixPress 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.
Here is what just happened.
set -g prefix C-a made tmux wait for C-a. unbind C-b removed the stale send-prefix binding, and bind C-a send-prefix gave the new key the same escape hatch, so C-a C-a reaches the shell. Sourcing applied all three at once; C-a c then ran the same new-window that C-b c always did.
- Change the prefix key:set -g prefix C-a
- Pressing the prefix twice sends it to the program:bind C-a send-prefix
Go further
- Test a prefix without the file: type the three commands at the prompt, using
C-b :before andC-a :after. - Many people keep both keys during the transition with
bind C-b send-prefixas well. tmux show -gv prefixfrom the shell prints the current prefix.
- 1After sourcing, the prefix is
C-a. Opening the new window isC-a c, notC-b c. - 2Three lines:
set -g prefix C-a,unbind C-b,bind C-a send-prefix, in that order. - 3
open ~/.tmux.conf, add them, Ctrl-S. ThenC-b :one last time andsource ~/.tmux.conf.
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
Alpine Linux and tmux 3.4 on an x86 emulator. Nothing to install, and no server behind it.
about 15 MB, once
Done when
not started- The prefix option is set to C-a— not done yet
- C-a is bound in the prefix table to send-prefix— not done yet
- C-b is no longer bound in the prefix table— not done yet
- A second window exists in session learn, opened with the new prefix— not done yet