Check what keys tmux can detect from the terminal being used.
When a key is pressed and it was identified, its tmux name is displayed
on the status line, like C-M-Up
Terminals often have some issues, for some keys they might generate the wrong thing, or even nothing. Using this can give help to select the right terminal, or if one is already selected, it can show what keys are available to use. Some terminals offer good suport in defining what sequence can be sent when pressing a key, this is unfortunately not always the case.
If the Operating System or terminal binds some keys, they will not be detected by tmux. Sometims it is possible to disable such usages of a key that would make more sense to handle by tmux.
I have only defined the letters a-z and the Swedish umlauts, contributions for other characters would be apreciated!
Clone this, then run keybtest.sh
This will start a tmux session that will display the tmux notation for any key pressed that tmux could recognize. Be aware that some keys might not send the intended sequence, so tmux will interperate it as something else!
The tmux key name prefixes are:
S-
Shift was pressed together with the keyC-
Control was pressed together with the keyM-
Alt was pressed together with the key
Use the names displayed here in your tmux.conf to bind that key to a desired action matching the current terminals capabilities.
It might be obvious, but this should not be run this inside another tmux session, since that would typically bind some keys.
The exit sequence C-x
C-x
is displayed in the status line, so usage
should be self-explainatory, without any need to memorize the exit sequence.
- The shifted regular keys are not tested, instead of binding
S-a
orS-A
useA
- cant be bound:
~ $ % & * { } | "
- Case is ignored, binding
C-A
afterC-a
will drop theC-a
bind, thus only binding lowercase here. Case is also ignored for key presses, so if bindingC-a
pressing ctrl+A will trigger that action and vice-versa. - Skipped to avoid collision
C-i
is the same asTab
C-m
is the same asEnter
C-[
is the same asEscape
- Regular keys Not tested, same as with
S-
- Regular keys Not tested, same as with
S-
-
cant be bound:
~ $ % & * { } | "
-
Case is ignored, binding
C-M-A
afterC-M-a
will drop theC-M-a
bind, thus only binding lowercase here. Case is also ignored for key presses, so if bindingC-M-a
pressing ctrl+alt+A will trigger that action and vice-versa. -
Skipped to avoid collision
C-M-i
is the same asC-M-tab
C-M-m
is the same asC-M-Enter
C-M-[
is the same asC-M-Escape
- cant be bound:
~ $ % & * { } | "
- Since this is using shift, no lower case keys are bound here
In the tmux universe the key for Insert is called IC
and Delete is
called DC
so if those are spotted, the terminal is doing the right thing!
If a key generates an unrecognized code, there is a high likelyhood that the terminal will beep, so if in a public spot, muting the sound might come in handy before running this.
Unrecognized keys will be printed.
If time allows, please submit such output in an issue, and I will add it! I will only need the character/character sequence displayed for a given key, ideally also what keyboard type generated it, but that is optional.
If what is generated is understood by tmux, but not what was intended,
like if S-F3
is generated by Alt+Up and S-F3
wont be used.
Just bind the action intended for Alt+Up to S-F3
- problem solved!
If it is not possible to alter what the terminal generates, but a key does generate something unique that tmux doesnt recognize, that sequence can be bound to the desired action by using user-keys.
Tmux is picky about notation for defining user-keys.
Remember to use octals prefixed by \\
and always give three digits,
so if the octal is 73 give it as \\073
Octals are normally in the middle column when using showkeys -a
It might be somewhat confusing, when defining a user-key an index is used,
but when binding it, the index is used as a suffix to User
.
See this sample:
set -s user-keys[101] "\\342\\201\\204"
bind -n User101 send-keys F1
To check what sequence a key generates by the terminal, here are some suggestions, should be run outside tmux, since it might capture keys.
- showkeys -a
- xxd