tmux 选项`xterm-keys` 不启用控制+箭头

kkm*_*kkm 8 tmux inputrc

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

"\eOD": backward-word
"\e[1;5D": backward-word
Run Code Online (Sandbox Code Playgroud)

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

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

:show-window-options -g
Run Code Online (Sandbox Code Playgroud)

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

:set-window-option xterm-keys on
Run Code Online (Sandbox Code Playgroud)

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

我还可以检查什么来解决此问题?

Tho*_*key 5

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

:set-window-option xterm-keys on
Run Code Online (Sandbox Code Playgroud)

进行中

:set-window-option -g xterm-keys on
Run Code Online (Sandbox Code Playgroud)

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

commit 5ee4d991b6a325848083017665ac3d3ace2d1fa1                                 
Author: Nicholas Marriott <nicholas.marriott@gmail.com>                         
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.
Run Code Online (Sandbox Code Playgroud)

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

如果-g指定,则设置全局会话窗口选项。
对于-a,如果该选项需要一个字符串,则值将附加到
现有设置中。该-u标志取消设置选项,因此会话
全局选项继承该选项。无法
取消设置全局选项。

其中的关键部分是会话,它是启动 时创建的一组伪终端tmux