为什么我不能将 inputrc 中的 \C-e 设置为 vi 命令键盘映射的行尾?

Why can't I set \C-e in inputrc to be end-of-line for vi-command keymap?

我的 .inputrc 中有这个,但 Control-e 在命令模式下不会移动到行尾。所有其他绑定都有效。

$if mode=vi
    set show-mode-in-prompt on

    set keymap vi-insert
    "\C-e": end-of-line
    "\C-a": beginning-of-line

    set keymap vi-command
    "\C-e": end-of-line
    "\C-a": beginning-of-line
$endif

我可以看到它正在占用:

$ bind -p | grep 'end-of-line'
"\C-e": end-of-line
"\eOF": end-of-line
"\e[F": end-of-line

而且我看不出还有什么绑定到 \C-e:

$ bind -p | grep 'C-e'
"\C-e": end-of-line
"\C-x\C-e": shell-expand-line

如果我将它设置为\C-l,它就可以工作。那么,readline 的 vi 模式中的 \C-e 有什么特别之处我无法覆盖?

唯一的其他线索是 \C-e 导致终端发出哔哔声。

我的 .inputrc 中没有其他内容

我刚刚试过了,它也不适合我。但是 bind 命令工作正常:

bind -m vi-command ' "\C-e": end-of-line '

readline 加载似乎有些奇怪 .inputrc。因此,作为解决方法,您可以将 bind 命令放入 bashrc 文件中。

根据 Chet Ramey 通过 bug-bash@gnu.org 邮件列表,

This has been there forever. The default readline vi command-mode keymap has ^E bound to switch to emacs editing mode. Since bash uses `set -o emacs' for that, the bash readline initialization code unbinds the key sequence. It needs to make sure that the function it's bound to is still rl_emacs_editing_mode.

他提供了一个补丁,这可能超出了这里的 SO 答案的范围,所以我只 link 给它:http://lists.gnu.org/archive/html/bug-bash/2019-01/msg00217.html

@pynex 的解决方法工作正常。