Tmux: how do I bind function keys to commands?

给你一囗甜甜゛ 提交于 2020-01-01 10:09:36

问题


How do I bind a function key (e.g. F1, which generates ESC O P) to a tmux command (e.g. "next window", ctrl-B n)?

Context: ssh running on mac into tmux session on linux. I'm pressing fn-F1 on the mac keyboard to generate the ESC O P.


回答1:


From the KEY BINDINGS section of man tmux:

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 F12, Home, IC (Insert), NPage/PageDown/PgDn, PPage/PageUp/PgUp, Space, and Tab.


bind-key [-cnr] [-t mode-table] [-T key-table] key command [arguments] (alias: bind)

Bind key key to command. Keys are bound in a key table. By default (without -T), the key is bound in the prefix key table. This table is used for keys pressed after the prefix key (for example, by default ‘c’ is bound to new-window in the prefix table, so ‘C-b c’ creates a new window). The root table is used for keys pressed without the prefix key: binding ‘c’ to new-window in the root table (not recommended) means a plain ‘c’ will create a new window. -n is an alias for -T root. Keys may also be bound in custom key tables and the switch-client -T command used to switch to them from a key binding. The -r flag indicates this key may repeat, see the repeat-time option.

Therefore, bind-key -n F1 next-window would allow you to hit fn-F1 on your macbook to switch to the next window in your tmux session.



来源:https://stackoverflow.com/questions/38967247/tmux-how-do-i-bind-function-keys-to-commands

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!