i just started using tmux and have been trying to bind my MENU key to prefix but it is giving me "bad key bind error", it would be nice to know what keys are valid or what to write in the conf file for keys to work
1 Answer
tmux's documentation is a little vague on the topic (defining the prefix key):
prefixkey
Set the key accepted as a prefix key. In addition to the standard keys described under KEY BINDINGS, prefix can be set to the special key ‘None’ to set no prefix.
But reading the source code here
if (cmd_get_entry(self) == &cmd_send_prefix_entry) { if (args_has(args, '2')) key = options_get_number(s->options, "prefix2"); else key = options_get_number(s->options, "prefix"); cmd_send_keys_inject_key(item, item, key); return (CMD_RETURN_NORMAL); } tells us that (key_code is an unsigned long) tmux expects the prefix to be a single byte – or something that it can associate with a number. It performs that association via the terminal database (and is a little biased toward the entries for screen and xterm).
In the manual page, where it says
In addition, the following special key names are accepted:
it is referring to names associated with terminfo capabilities, with the possibility of using hard-coded strings for missing capabilities. The association is built up via a few tables, which you can see in
MENU would be something that you can "just use" in tmux if it sends a string matching one of the named special keys that are documented for tmux. On my keyboard, the Menu-key sends this (yours may differ):
^[[29~ which would be \E[29~ in terminfo. However, none of the keys listed in the default xterm terminal description do that. For some non-default terminal descriptions, it may be F10 (as a VT220) or F16 (as a VT420), making it possible with xterm (by changing the keyboard type and setting a different TERM).
For other terminal emulators, you may be able to change what the MENU key sends, e.g., as one of the function keys F1 through F12.