32

I was trying to learn how to use the bind-key [-cnr] [-t key-table] key command [arguments] better, but was having some trouble figuring out what "valid keys" are for bind-key command.

I tried doing man tmux and Google too, but I couldn't find anything useful.

  • How can I figure out what the syntax for valid keys are?
  • Is there a help command or a man page for this?
  • Maybe I don't know the technical term for this valid keys, is there a term for these keys so that I can do a better google search?

For example, I was trying to figure out what the following remapping of commands meant:

bind-key -n M-S-Left resize-pane -L 2
bind-key -n M-S-Right resize-pane -R 2
bind-key -n M-S-Up resize-pane -U 2
bind-key -n M-S-Down resize-pane -D 4

The -n was easy to find in the man page (doesn't need prefix). But I can't figure out what M-S-Left key means.

I am guessing that its mapping shift and the left arrow plus whatever M means to the resize-pane -L 2 command.

  • How do I figure out what M means?
  • What if I wanted control + whatever key I wanted. Is control = C ?
  • How can I figure this out without just trying random keys on my keyboard until something works?
  • Also, how do I confirm, figure out if I am not mapping it to a key set that is already used?
  • Is there such a thing as "show all aliases" or something?
  • As an addition to the question, are these valid keys the same as the ones for vim?

The thing is that vim seems to have a different scripting for its own language since it sometimes require and stuff.

5
  • 3
    M stands for Meta which is the Alt key on a PC keyboard.
    – schaiba
    Commented Jun 30, 2014 at 18:11
  • 1
    thanks for that particular example! But it would be nice to know in general how to be able to figure this type of things on my own without having to come to stachexchange to ask for each key that I need. Commented Jun 30, 2014 at 18:16
  • 1
    I hope I answered your questions :). I'll try to find an answer for the vim questions :).
    – polym
    Commented Jun 30, 2014 at 18:41
  • yes it did! that was awesome! Thanks! :) It didn't let me accept cuz u answered so soon after I posted the question! lol :) thnx again. :) Commented Jun 30, 2014 at 18:42
  • 1
    Haha no probs :). tmux is awesome!
    – polym
    Commented Jun 30, 2014 at 18:48

2 Answers 2

39

Available Keys

Look at man tmux, search / for KEY BINDINGS:

tmux allows a command to be bound to most keys, with or without a prefix key.

When specifying keys, most represent themselves (for example ‘A’ to ‘Z’). Ctrl keys may be prefixed with ‘C-’ or ‘^’, and Alt (meta) with ‘M-’.

In addition, the following special key names are accepted:

Up, Down, Left, Right, BSpace, BTab, DC (Delete), End, Enter, Escape, F1 to F20, Home, IC (Insert), NPage/PageDown/PgDn, PPage/PageUp/PgUp, Space, and Tab. Note that to bind the ‘"’ or ‘'’ keys, quotation marks are necessary [...]

M-S-Left should be Alt+Shift+Left for example.


List all bound keys

To list all key bindings, simply press Ctrl-b then ? while in a tmux session.

This is also documented in man tmux in section EXAMPLES:

Typing ‘C-b ?’ lists the current key bindings in the current window; up and down may be used to navigate the list or ‘q’ to exit from it.

You can also list all key-bindings via tmux list-keys. If you want to check for already set keys, you can grep it's output to check, if it's already set.


Research

To find more via Google, search for Section names in man tmux - just type in tmux default key bindings for example :). But often man tmux is sufficient.

This site is a very good documentation about tmux and pops up, if you search for said string in Google.

Arch wiki is always good, too.

4
  • how does one actually use alt for MAC computers? I guess its different from the option key. Commented Jan 28, 2016 at 22:19
  • @CharlieParker "Alt" would be the "Meta" key .... In Mac OS terminal, in Terminal preferences, under "Profiles", choose a profile (like the one you're using), then in "Keyboard" tab, there is a checkbox, "Use Option as Meta key". Then you can use the alt/option key for Meta ... not sure what the default "Meta" keybinding is on Mac though ... might be Command, but Command doesn't get sent to the terminal session; appears to be grabbed by the system first. Commented Dec 17, 2016 at 20:17
  • And apparently "BTab" means "Shift-Tab" ... not sure what "BSpace" is ... when I tried to map something to "BSpace" and then tried to trigger with prefix, Shift+Space, it ended up doing "Next Layout" which is by default bound to prefix, space. Commented Dec 17, 2016 at 20:24
  • F keys > 12 have changed : github.com/tmux/tmux/commit/…
    – Delapouite
    Commented Feb 5, 2017 at 19:46
16

This is the full list of 'extended' key names available in tmux 2.2 (ripped from the source):

    /* Function keys. */
F1
F2
F3
F4
F5
F6
F7
F8
F9
F10
F11
F12
IC
DC
Home
End
NPage
PageDown
PgDn
PPage
PageUp
PgUp
Tab
BTab
Space
BSpace
Enter
Escape
    /* Arrow keys. */
Up
Down
Left
Right
    /* Numeric keypad. */
KP/
KP*
KP-
KP7
KP8
KP9
KP+
KP4
KP5
KP6
KP1
KP2
KP3
KPEnter
KP0
KP.
    /* Mouse keys. */
MouseDown1Pane
MouseDown1Status
MouseDown1Border
MouseDown2Pane
MouseDown2Status
MouseDown2Border
MouseDown3Pane
MouseDown3Status
MouseDown3Border
MouseUp1Pane
MouseUp1Status
MouseUp1Border
MouseUp2Pane
MouseUp2Status
MouseUp2Border
MouseUp3Pane
MouseUp3Status
MouseUp3Border
MouseDrag1Pane
MouseDrag1Status
MouseDrag1Border
MouseDrag2Pane
MouseDrag2Status
MouseDrag2Border
MouseDrag3Pane
MouseDrag3Status
MouseDrag3Border
MouseDragEnd1Pane
MouseDragEnd1Status
MouseDragEnd1Border
MouseDragEnd2Pane
MouseDragEnd2Status
MouseDragEnd2Border
MouseDragEnd3Pane
MouseDragEnd3Status
MouseDragEnd3Border
WheelUpPane
WheelUpStatus
WheelUpBorder
WheelDownPane
WheelDownStatus
WheelDownBorder

These can be used in addition to ASCII printable characters set and combined with M-, C-, and S- prefixes.

1
  • No Alt-Gr makes me sad. Wonder how hard would it be to add.
    – solarc
    Commented Feb 6, 2017 at 15:30

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .