Linux 在 tmux 中绑定 Ctrl+Tab 和 Ctrl+Shift+Tab

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/15470001/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-06 22:28:51  来源:igfitidea点击:

Bind Ctrl+Tab and Ctrl+Shift+Tab in tmux

linuxputtytmuxxtermgentoo

提问by dook

I'm trying to a get a ctrl+taband ctrl+shift+tabbinding to work inside of a tmux session (I'm also using PuTTY).

我正在尝试在tmux 会话中使用ctrl+tabctrl+ shift+tab绑定(我也在使用 PuTTY)。

I already went through the pains of having to recompile PuTTY so it would send ctrland shift correctly. After using ctrl+v, and I'm able to see that ^[[27;5;9~and ^[[27;6;9~are being sent for ctrl+taband ctrl+shift+tab, respectively. Is there any way I can get these bound to next-window and previous-window inside of tmux?

我已经通过重新编译腻子所以它会发出的痛苦去ctrlshift 正确。使用ctrl+ 后v,我能够看到^[[27;5;9~^[[27;6;9~分别发送ctrl+tabctrl+ shift+ tab。有什么办法可以让这些绑定到 tmux 内的下一个窗口和上一个窗口?

Edit: After some research, I'm thinking I might have to configure xterm to include those keycodes. Any idea how I would go about doing that?

编辑:经过一些研究,我想我可能必须配置 xterm 以包含这些键码。知道我将如何去做吗?

Edit2: So I found out I can retrieve infocmp and recompile it. I added

Edit2:所以我发现我可以检索 infocmp 并重新编译它。我加了

kctab=\E[27;5;9~, kcstab=\E[27;6;9~,

kctab=\E[27;5;9~, kcstab=\E[27;6;9~,

to the end of it, except now it's giving me an error. "entry does not start with terminal names in column one"

到最后,除了现在它给了我一个错误。“条目不以第一列中的终端名称开头

采纳答案by Chris Johnsen

Recent “unreleased” versions of tmuxdo automatically recognize those xterm-style key sequences once you have your terminal sending them (no need to change your terminfo entry). The next release version (1.8?) should also have this support. With an appropriate build of tmux1, all you have to do is bind the keys in your tmuxconfiguration:

一旦您的终端发送它们(无需更改您的 terminfo 条目),最近“未发布”版本的tmux会自动识别那些 xterm 样式的键序列。下一个发布版本(1.8?)也应该有这个支持。使用适当的tmux 1构建,您所要做的就是在tmux配置中绑定键:

bind-key C-Tab next-window
bind-key C-S-Tab previous-window

You will still need to type your prefix key before these keys.

您仍然需要在这些键之前键入您的前缀键。

(Note: ~/.tmux.confis only processed when the server starts. If you make changes to it, you will either need to exit all your sessions and restart the server, or use (e.g.) tmux source ~/.tmux.confto have your existing server re-process the file.)

(注意:~/.tmux.conf仅在服务器启动时处理。如果您对其进行更改,您将需要退出所有会话并重新启动服务器,或者使用(例如)tmux source ~/.tmux.conf让您现有的服务器重新处理文件。)

Also, if you want tmuxto pass along these (and other) xterm-style key sequences to programs running inside tmux, then you will need to enable the xterm-keyswindow option.

此外,如果您希望tmux将这些(和其他)xterm 样式的键序列传递给在tmux内运行的程序,那么您将需要启用xterm-keyswindow 选项。

set-option -gw xterm-keys on

(If you prefer, you can do this on a per-window basis by using -winstead of -gw.)

(如果您愿意,可以使用-w代替 ,在每个窗口的基础上执行此操作-gw。)



If you want to be able to use those keys without typing the prefix, then you can use “no prefix” bindings instead:

如果您希望能够在不键入前缀的情况下使用这些键,那么您可以使用“无前缀”绑定:

bind-key -n C-Tab next-window
bind-key -n C-S-Tab previous-window

This will more or less “dedicate” the keys to tmux, though. It will be difficult to type these keys to any program running inside tmux(e.g. you would have to use the tmuxcommand send-keys C-Tab—as normal, xterm-keysmust be enabled to send these xterm-style key sequences).

不过,这或多或少将“专用”密钥给tmux。很难将这些键输入到tmux 中运行的任何程序中(例如,您必须使用tmux命令send-keys C-Tab——通常,xterm-keys必须启用才能发送这些 xterm 样式的键序列)。



The problem with your terminfo entry editing is probably because each line after the one that names the terminal type needs to start with a Tab. Lines that do not start with a tab are the beginning of a new terminal entry. Technically, the NL TAB sequence is basically a line continuation in this file format; each entry is a single logical line.

编辑 terminfo 条目的问题可能是因为命名终端类型的行之后的每一行都需要以 Tab 开头。不以制表符开头的行是新终端条目的开始。从技术上讲,NL TAB 序列基本上是这种文件格式中的行延续;每个条目都是一个逻辑行。

Also, if you are redefining terminfo entries, be sure to use -xwith infocmpand ticto preserve the user-defined capabilities (some of which are fairly standard).

此外,如果您要重新定义 terminfo 条目,请确保-xinfocmptic一起使用以保留用户定义的功能(其中一些是相当标准的)。



1I.e. built from recent code in the tmuxGit repository at sf.net(at the clone-able URL git://git.code.sf.net/p/tmux/tmux-code).

1即从sf.nettmuxGit 存储库中的最新代码构建(位于可克隆的 URL 处git://git.code.sf.net/p/tmux/tmux-code)。