jholley
jholley

Reputation: 53

Make tmux prefix binding always act as prefix, and prefix only (idempotent binding)?

I've been through the subreddit and the SO tag as well as a couple of pages of multiple phrasings of a Google search, and I can't find any threads/topics/pages that address this, so here goes:

I want the prefix key in tmux to always 'activate' the prefix in tmux. Let me explain what I mean - from the man page:

tmux may be controlled from an attached client by using a key combination of a prefix key, `C-b' (Ctrl-b) by default, followed by a command key. The default command key bindings are:

C-b

Send the prefix key (C-b) through to the application.

I don't have 'send-prefix' in my tmux.conf set to send the prefix combination to the application when pressed twice, but the result seems to be that the prefix now acts as a 'toggle'. Press it once, and the next key is interpreted as a command. Press it twice and the next key is sent directly to the application. For example:

I would like to make it so regardless of how many times the prefix is pressed, the next key pressed is always interpreted as a command (i.e. the two keystroke sequences above to give the same result).

Thanks in advance!


If you're wondering why I want this, suffice to say it has to do with a very complex tmux.conf file and the repeatable flag on a lot, but not nearly all, of my key bindings. I'm so accustomed to having to press the prefix immediately before the non-repeatable bindings that I always hit it, even if I've just finished using a repeatable command. This looks like a 'second' press of the prefix to tmux, which makes sends my command key to the terminal. Edge case, I know, but if it is possible to turn this behavior off it would save me a ton of mistaken keystrokes!

Upvotes: 2

Views: 730

Answers (1)

chepner
chepner

Reputation: 531858

This should do the trick:

bind-key C-b switch-client -Tprefix

It makes more sense if you think of the prefix not as a special key, but simply one bound in the root table that also calls switch-client -T:

# Equivalent to 'set-option -g prefix C-b'?
bind-key -Troot C-b switch-client -Tprefix

Upvotes: 1

Related Questions