tmux 选项 `xterm-keys` 不启用 control+arrows

tmux 选项 `xterm-keys` 不启用 control+arrows

我无法使 tmux 识别Ctrl-Left-arrow序列与左箭头不同,右箭头也相同。在我的 中~/.inputrc,我映射了这些序列(由 2 个不同的终端模拟器发出,即 putty 和 mobaxterm)以跳过命令行中的单词:

"\eOD": backward-word
"\e[1;5D": backward-word

这在 ssh 会话中工作得很好,但是 screen 和 tmux 都不区分箭头和控制箭头。自然,推荐的解决方案是通过添加全局选项来启用 tmux 中的 xterm-keys 选项~/.tmux.conf,并且有直接证据(除了对上述解决方案的“感谢”评论之外)这对其他人也有效。但对我来说,Ctrl-发送与Left-arrow相同的代码。ESC DLeft-arrow

我已经通过检查 tmux 选项确认该选项确实已设置

:show-window-options -g

甚至可以手动设置它以防当前窗口

:set-window-option xterm-keys on

但这一切都无济于事。 tmux 报告版本号 1.8,扩展名为tmux -V.

我还可以检查哪些内容来解决此问题?

答案1

您应该-g在这一行中使用(全局)选项:

:set-window-option xterm-keys on

进行中

:set-window-option -g xterm-keys on

对于 tmux 1.8。但是,tmux 3.3 默认启用此功能(更改为2020年5月, 发布2022 年 6 月):

commit 5ee4d991b6a325848083017665ac3d3ace2d1fa1                                 
Author: Nicholas Marriott <[email protected]>                         
Date:   Fri May 15 10:31:54 2020 +0100

    xterm-keys has been on by default for 5 years and all other modern terminals
    use these key sequences by default. Merge the code into the main tty and input
    tree processing (convering the latter to use a tree rather than a table at the
    same time) and make the option a no-op.

tmux手动的不是很清楚,说的是-g

如果-g被指定时,全球会议或者窗户选项已设置。
-a,如果该选项需要一个字符串,价值附加到
现有设置。这-uflag 取消设置选项,因此会话
全球的选项。无法
取消设置全球的选项。

这的关键部分是会议,这是当您创建时创建的一组伪终端开始 tmux

相关内容