Backspace 在 tmux 命令提示符下不起作用 [英] Backspace not working in tmux command prompt

查看:104
本文介绍了Backspace 在 tmux 命令提示符下不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在 tmux 命令提示符下使用 Backspace 键时遇到问题.退格键会删除 tmux 中的先前字符(如预期),但不会删除 tmux 命令提示符.例如, :lists 不会删除 's' 字符.在这种情况下,使用 C-h 而不是 Delete 键确实可以删除s"字符.C-? 不会删除 's' 字符.我在 tmux 窗口中进行了一些调试:

I'm having trouble with my Backspace key on the tmux command prompt. The backspace deletes previous characters (as expected) within tmux but not on the tmux command prompt. For example, <PREFIX>:lists<DEL> will not delete the 's' character. Using C-h instead of the Delete key does delete the 's' character in this situation. C-? does NOT delete the 's' character. Some debugging I've done within the tmux window:

$TERM=screen-256color
infocmp reports kbs=\177                  (good)
appres XTerm | grep backarrowKeyIsErase   reports as true (good)
appres XTerm | grep ptyInitialErase       reports as true (good)
stty -a | grep erase                      reports as "^H" (bad, I think I want ^?)

我还尝试将 .tmux.conf 中的 Backspace 键绑定到 ChC-?,如下所示,既不工作.tmux 中的 :list-keys 确认映射正在发生.

I've also tried binding the Backspace key in the .tmux.conf as shown below to both C-h and C-?, neither work. :list-keys within tmux confirms that the mapping is occurring.

bind-key -n BSpace send-keys C-?

在调用 tmux 之前和之后,我也做了一个 stty 擦除 ^? 并且这不会影响行为.最后,我完全删除了我的 .tmux.conf 并且仍然得到相同的行为.

I've done a stty erase ^? as well, both before and after invoking tmux and that does not affect the behavior. Finally, I've removed my .tmux.conf entirely and still get the same behavior.

命令行是否使用了一组不同的会影响 BSpace 功能的键绑定?

Does the command line use a different set of key bindings that would affect BSpace functionality?

推荐答案

问题是因为我的 $TERM 设置、我的 .Xdefaults、终端的键绑定(我使用 konsole)以及 tmux 发送的任何内容.我的具体修复要求在任何地方将 Backspace 设置为 ^? 而不是 ^h.此外,tmux 的 $TERM 最好设置为 screen-256colors 或 tmux-256colors,因此您需要确保这些终端模式可以看到正确的键映射.

The problem was because there was a mismatch between my $TERM settings, my .Xdefaults, the keybindings for the terminal (I use konsole) and whatever tmux was sending. My specific fix required getting Backspace set to ^? everywhere and NOT ^h. Additionally, tmux's $TERM is best set to screen-256colors or tmux-256colors so you need to ensure that those terminal modes can see the right key mappings.

在我的 .Xdefaults 中,请注意这适用于所有 VT100 而不仅仅是 XTerm*VT100,因为我希望 screen、tmux 和 konsole 看到这些条目:

In my .Xdefaults, note that this is for all VT100 and not just XTerm*VT100 because I want screen, tmux, and konsole to see these entries:

*VT100.Translations: #override \n\
   <Key>BackSpace:       string(0x7F) \n\
   <Key>Delete:          string("\033[3~")

*ttyModes: erase ^?

我还必须修复我的 ~/.cshrc 中的绑定键:

I also had to fix my bindkeys in my ~/.cshrc:

bindkey -a "\e[3~" delete-char
stty erase ^?

... 并将类似的条目添加到 ~/.inputrc 文件(konsole 读取):

... and also add a similar entry to an ~/.inputrc file (which konsole reads):

"\e[3~": delete-char

这篇关于Backspace 在 tmux 命令提示符下不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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