Changing your tmux prefix key from the default Ctrl-b is one of the first things most people do, and for good reason. The default is a bit awkward to press, especially if you’re used to Ctrl-a for terminal multiplexing in other tools like screen.

Here’s how you do it, and a few things to consider.

The Core Change

To change your prefix key, you need to edit your tmux configuration file, typically located at ~/.tmux.conf. You’ll add a line like this:

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

Let’s break this down:

  1. unbind C-b: This command explicitly tells tmux to stop listening for Ctrl-b as the prefix key. If you skip this, you’ll have two prefix keys (the old one and the new one), which is usually not what you want.

  2. set-option -g prefix C-a: This is the main command.

    • set-option: This is the general command to set any tmux option.
    • -g: This flag means the option is global, applying to all sessions.
    • prefix C-a: This sets the prefix key to Ctrl-a. You can substitute C-a with any other key combination. Common alternatives include C-z or M-a (Alt-a).
  3. bind-key C-a send-prefix: This is crucial. After you’ve changed the prefix key, you still need a way to send the actual Ctrl-a character to applications running inside tmux (like a shell that might use Ctrl-a for command-line editing). This line binds Ctrl-a again, but this time it tells tmux to send-prefix, meaning it will pass the Ctrl-a character through to the application.

Reloading Your Config

After saving your ~/.tmux.conf file, you need to tell tmux to reload its configuration. You can do this in a few ways:

  • If tmux is already running:

    1. Press your current prefix key (which is still Ctrl-b until you reload).
    2. Type :source-file ~/.tmux.conf and press Enter.
    3. Now, your new prefix key (Ctrl-a in our example) will be active.
  • When starting a new tmux session: If you’re starting tmux for the first time with the new config, or if you’ve closed all sessions, the new prefix key will be active automatically when you run tmux.

Many users, especially those coming from the older screen utility, are deeply accustomed to Ctrl-a as their primary modifier. It’s a comfortable key combination for many keyboard layouts. Migrating to Ctrl-a in tmux offers a familiar workflow without sacrificing tmux’s power.

What Else Can You Do?

The prefix key isn’t just for triggering commands. It’s the gateway to virtually all tmux functionality. You can rebind almost any tmux command to a key combination that follows your prefix.

For example, to bind Ctrl-a followed by h to split the current pane horizontally:

bind-key h split-window -h

And to split vertically:

bind-key v split-window -v

You can also combine commands. If you want Ctrl-a followed by k to kill the current pane, and Ctrl-a followed by l to kill the current window:

bind-key k kill-pane
bind-key l kill-window

The Counterintuitive Part: Key Order Matters

You might think that since you’ve unbound Ctrl-b and set Ctrl-a as the prefix, any command you then type is independent. But the order in which you define these bindings in your ~/.tmux.conf file can matter, especially if you’re trying to create complex sequences or re-use keys.

Consider this scenario: You want Ctrl-a to be your prefix, but you also want to bind Ctrl-a itself to do something other than just sending the prefix character. This is where bind-key -n comes in, which binds a key without requiring the prefix. However, if you try to bind Ctrl-a with -n after you’ve set it as the prefix, tmux might get confused. The unbind C-b and set-option -g prefix C-a commands should generally come before any bind-key commands that use the new prefix, and crucially, before any bind-key -n that might conflict with the prefix key itself. The bind-key C-a send-prefix line is what allows the C-a key to retain its dual purpose: as a prefix trigger and as a character to be sent when followed by another C-a (e.g., C-a C-a to send the literal Ctrl-a character).

If you mess up your ~/.tmux.conf and tmux becomes unresponsive to your prefix, you can often recover by killing the tmux server process. On Linux/macOS, this is usually pkill tmux.

The next thing you’ll likely want to customize is how your panes and windows are navigated.

Want structured learning?

Take the full Tmux course →