使用Alt+左/右箭头在tmux中切换窗口

8
我正在尝试配置tmux,以便使用alt-left,alt-right序列在窗口之间切换。以下是我在.tmux.conf中的配置:
bind-key -n M-Left previous-window
bind-key -n M-Right next-window

很遗憾,它不起作用。在我的机器上,alt-left和alt-right分别绑定为^[[1;3D和^[[1;3C。我认为我必须使用terminfo覆盖来告诉tmux使用这些序列,但我不知道如何操作。因此,任何帮助都将不胜感激。
谢谢!

tmux 应该自动识别这些序列,不管你在外部使用什么 TERM(终端类型),也不管相应的 terminfo 条目说什么。在将这些条目加入配置文件后,您是否重新启动了 tmux 服务器?如果所有命令都是幂等的,您可以在现有服务器中运行 source ~/.tmux.conf 来获取更改。 - Chris Johnsen
@ChrisJohnsen 我非常确定 tmux 选择了这个配置。 - Alexander Sandler
1
你有没有找到这个问题的答案?我在使用Ubuntu 12.04,terminator 0.96和tmux 1.9a遇到了同样的问题。 - danns87
我刚在Ubuntu 16.04上尝试了一下,对我来说可以工作。 - Ondřej Čertík
1个回答

1
如果关闭了 xterm-keys 选项,tmux 将忽略这些按键(因为当选项未设置时,它会识别并丢弃这些按键)。tmux 的用户一直对此存在疑惑,并且在 end of 2016,开发者更改了该选项的默认设置。
Change the xterm-keys option to default to on, so that tmux will generate xterm(1) escape sequences for function keys with modifiers.

With the option off most of these keys are ignored by default, except
for ctrl + arrows which use a variant that nothing else seems to use and
I don't remember why we chose. The xterm escape sequences are now the
most common.

正如我在tmux on remote machine not getting correct prefix + arrow keys中指出的那样,这仍然依赖于终端描述。


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接