brewedbits.dev

Personal blog with guides and news on selfhosting, Linux and AI, from the Netherlands

nextDash nextdash --aboutYour bookmarks. Your terminal. checks your links knows your Docker host one container, no cloudLive demo →nextdash.cc ↗

Tip: set -g prefix2 gives tmux a second prefix key next to Ctrl-b

Tmux
~/tips/tip-tmux-prefix2

set -g prefix2 C-a

Lets tmux accept a second prefix key, so Ctrl-b and Ctrl-a both work.

Moving the tmux prefix to Ctrl-a is old advice, and the catch is that every cheat sheet, guide and colleague still says Ctrl-b. tmux has a second prefix option, so you can keep both.

set -g prefix2 C-a
bind C-a send-prefix -2

The first line makes Ctrl-a a prefix next to Ctrl-b. Ctrl-a c opens a window, Ctrl-b c still does too. The second line binds Ctrl-a in the prefix table to send-prefix -2, which sends the second prefix key to the program in the pane. So pressing Ctrl-a twice gives the shell a real Ctrl-a, which in bash and zsh jumps to the start of the line.

I like this as a soft move. Your fingers can learn the closer key while Ctrl-b keeps working, and a config you share with someone else doesn’t break their habits.

prefix2 is a session option, and -g sets it for all sessions. Check what it is now with:

tmux show -g prefix2

Out of the box the answer is prefix2 None. Put both lines in ~/.tmux.conf and reload, or type them after Ctrl-b : to try them first.

The price is that tmux now owns Ctrl-a. Every program in every pane only gets it when you press it twice: the shell, Emacs-style keys in other tools, and GNU screen if you ever run it inside tmux. If that bothers you, pick a key you never use, or turn it off again with set -g prefix2 None.

Further reading: tmux manual page (OpenBSD), tmux wiki: Getting Started

Going deeper: Guide: advanced tmux, a config that grows with you, formats, layouts and more

More Tmux tips set -s extended-keys on set -s history-file ~/.tmux_history tmux list-keys -T prefix ] bind S run-shell -b '~/bin/sync-notes.sh' set -g status-justify centre All Tmux tips (133) All topics

Link