How to control a nested tmux session (send the prefix to the inner one)?

By Romain Dorgueil

Short answer

# ~/.tmux.conf, when your prefix is C-a
bind C-a send-prefix   # double C-a then targets the inner tmux

With the stock C-b prefix this already works as C-b C-b, because prefix C-b is bound to send-prefix by default.

Details

Run a tmux inside another one (a local session plus a second tmux over SSH, say) and a problem appears: the outer tmux grabs the prefix key first, so every shortcut hits the outer session and the inner one never sees it. The fix is to forward the prefix on demand.

send-prefix does exactly that: it passes one prefix keystroke through to the program running inside the current pane. tmux binds it to prefix C-b out of the box, so with the default prefix you press C-b once for “I want to talk to tmux” and a second C-b for “send it inward”.

Once you change your prefix to C-a, that default pairing no longer matches your muscle memory. Add bind C-a send-prefix and a double C-a C-a forwards the prefix to the inner tmux, while a single C-a still drives the outer one.

The other option is to avoid the collision entirely: give the inner tmux a different prefix (for example C-b on the remote host, C-a locally). No forwarding needed, at the cost of remembering which key belongs to which level.

Verified on tmux 3.2a: by default C-b is bound to send-prefix in the prefix table; after set -g prefix C-a and bind C-a send-prefix, both C-a and C-b send the prefix.