Is there some way I can bind ; (\059) to a command in tmux?
By default, it is bound to last-pane; however, I would like to rebind it to select-pane -R.
I have tried putting the following in my .tmux.conf, but none seem to work:
"bind \059 select-pane -R" -> tmux reports "unkown key \059", but after ignoring the warning, ";" sometimes does work as intended.
"bind ; select-pane -R" -> tmux reports "usage: bind-key ..."
"bind ';' select-pane -R" -> tmux reports "usage: bind-key ..."
I'm using the first option now, but I'd like to do it correctly so I don't have a warning appear every time I start tmux.
Semi-colon is also used as a command separator in tmux, so in order to bind it, you need to escape it:
bind-key \; select-pane -R
tmux quoting is a bit quirky; it looks very much like Bourne shell-style quoting, but it has subtle differences.
The only thing that works to escape a trailing (or lone) semicolon is a backslash:
bind \; select-pane -R
The relevant part of the man page:
A literal semicolon may be included by escaping it with a backslash (for example, when specifying a command sequence to bind-key).
A trailing, unescaped semicolon acts as a separator between tmux commands.
tmux is showing you the bind-key
usage (for your examples numbered 2 and 3) because when the semicolon is unescaped (even when it is quoted, unlike the shell), the line is parsed as two commands: bind
and select-pane -R
. The first of those commands is incomplete (bind-key
requires at least two arguments: a key and a command).
Your \059
attempt (your example numbered 1) was likewise failing to adjust the bindings because the octal syntax is not supported when specifying keys. The default binding for Prefix ; is last-pane
, which may end up moving a pane to the right (i.e. what select-pane -R
does), but only if the next pane to the right happens to be the previously active pane.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With