【发布时间】:2013-09-03 19:38:36
【问题描述】:
我目前正在使用带有 xterm-256color $TERM 变量的 tmux。在 tmux 下的 bash 中,按 home/end 会插入波浪字符 (~)。在 tmux 之外,home/end 键可以正常工作。
使用 cat 和 tput,我可以看到生成的序列和预期的序列不匹配:
$ cat -v # pressing home, then end
^[[1~^[[4~
$ tput khome | cat -v; echo
^[OH
$ tput kend | cat -v; echo
^[OF
为了解决这个问题,我决定在我的 .bashrc 中添加以下内容:
if [[ -n "$TMUX" ]]; then
bind '"\e[1~":"\eOH"'
bind '"\e[4~":"\eOF"'
fi
这解决了 bash 的问题,但是在其他 readline 程序中,例如在 ipython 等 REPL 中,它仍然为 home/end 插入波浪号。
为什么首先这是一个问题?为什么当我在 tmux 内部和外部时生成的序列不同?如何解决此问题,使其在任何程序中都不是问题?
【问题讨论】:
-
这是一个 tmux 配置的好问题,但是我建议你尝试习惯
ctrl-A/E/F/B/alt-B/F...(emacs bind) 来移动光标 -
顺便说一句,如果这对你有帮助? stackoverflow.com/questions/8604150/…
-
我目前使用 ctrl-a 作为 tmux 中的命令键前缀(类似于 screen)。我之前看过那篇文章,但这似乎只适用于 Vim,在 Vim 中这对我来说不是问题。