Tmux:如何将功能键绑定到命令? [英] Tmux: how do I bind function keys to commands?

查看:38
本文介绍了Tmux:如何将功能键绑定到命令?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何将功能键(例如 F1,它生成 ESC OP)绑定到 tmux 命令(例如下一个窗口"、ctrl-B n)?

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)?

上下文:在 mac 上运行的 ssh 进入 linux 上的 tmux 会话.我在 mac 键盘上按下 fn-F1 以生成 ESC O P.

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.

推荐答案

来自 man tmuxKEY BINDINGS 部分:

tmux 允许将命令绑定到大多数键,带或不带前缀键.指定键时,大多数代表他们自己(例如A"到Z").Ctrl 键可能以C-"或^"为前缀,而 Alt(元)以M-"为前缀.此外,还接受以下特殊键名:Up、Down、Left、Right、BSpace、BTab、DC(删除)、End、Enter、Escape、F1 到 F12、Home、IC(插入), NPage/PageDown/PgDn, PPage/PageUp/PgUp, Space, and Tab.

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] 按键命令 [arguments](别名:bind)

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

将密钥绑定到命令.密钥绑定在密钥表中.默认情况下(不带 -T),键绑定在前缀键表中.该表用于在前缀键之后按下的键(例如,默认情况下‘c’绑定到前缀表中的新窗口,因此‘C-b c’创建一个新窗口).根表用于按下没有前缀键的键:将‘c’绑定到根表中的新窗口(不推荐)意味着普通的‘c’将创建一个新窗口.-n 是 -T root 的别名. 键也可以绑定在自定义键表中,并且 switch-client -T 命令用于从键绑定切换到它们.-r 标志表示此键可能重复,请参阅重复时间选项.

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.

因此,bind-key -n F1 next-window 将允许您在 macbook 上点击 fn-F1 以切换到 tmux 会话中的下一个窗口.

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.

这篇关于Tmux:如何将功能键绑定到命令?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆