在tmux中绑定Ctrl + Tab和Ctrl + Shift + Tab [英] Bind Ctrl+Tab and Ctrl+Shift+Tab in tmux

查看:210
本文介绍了在tmux中绑定Ctrl + Tab和Ctrl + Shift + Tab的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试获取 ctrl + tab ctrl + shift + 标签绑定以在tmux会话中工作(我也在使用PuTTY).

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

我已经经历了不得不重新编译PuTTY的痛苦,因此它可以正确发送 ctrl shift .使用 ctrl + v 之后,我能够看到正在为 ctrl + ^[[27;5;9~和^[[27;6;9~ > tab 和 ctrl + shift + tab .有什么办法可以将它们绑定到tmux内部的下一个窗口和上一个窗口?

I already went through the pains of having to recompile PuTTY so it would send ctrl and 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+tab and ctrl+shift+tab, respectively. Is there any way I can get these bound to next-window and previous-window inside of tmux?

经过一番研究,我认为我可能必须配置xterm使其包含那些键码.知道我会怎么做吗?

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?

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

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

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"

推荐答案

tmux 的最新未发布"版本会在您的终端将其发送后自动识别那些xterm样式的键序列(不需要更改您的terminfo条目).下一个发行版(1.8?)也应具有此支持.使用适当的 tmux 1 构建,您要做的就是将键绑定到 tmux 配置中:

Recent "unreleased" versions of tmux do 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 tmux configuration:

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.

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

(Note: ~/.tmux.conf is 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.conf to have your existing server re-process the file.)

此外,如果您希望 tmux 将这些(以及其他)xterm样式的键序列传递给在 tmux 中运行的程序,那么您将需要启用xterm-keys窗口选项.

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

set-option -gw xterm-keys on

(如果愿意,可以使用-w而不是-gw在每个窗口中执行此操作.)

(If you prefer, you can do this on a per-window basis by using -w instead of -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

这将或多或少地专用" temx 的键.很难在 tmux 中运行的任何程序中键入这些键(例如,您必须使用 tmux 命令send-keys C-Tab-通常,xterm-keys必须为可以发送这些xterm样式的键序列.

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 tmux command send-keys C-Tab—as normal, xterm-keys must be enabled to send these xterm-style key sequences).

terminfo条目编辑的问题可能是因为在命名终端类型的那一行之后的每一行都必须以Tab键开头.不以制表符开头的行是新终端条目的开头.从技术上讲,NL TAB序列基本上是此文件格式的换行符.每个条目都是一条逻辑行.

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条目,请确保将-x infocmp tic 一起使用,以保留用户定义的功能(其中一些功能相当标准).

Also, if you are redefining terminfo entries, be sure to use -x with infocmp and tic to preserve the user-defined capabilities (some of which are fairly standard).

1 即从 tmux Git存储库中的最新代码构建在sf.net 上(在可克隆的URL git://git.code.sf.net/p/tmux/tmux-code上).

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

这篇关于在tmux中绑定Ctrl + Tab和Ctrl + Shift + Tab的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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