Bash 自定义~/.inputrc定义不正确?

Bash 自定义~/.inputrc定义不正确?,bash,Bash,我的~/.inputrc中有以下内容: set input-meta on set output-meta on set convert-meta off # To use these in ITerm2 you may also need to configure preferences to send the correct escape # code for the key combination. # Option + Arrows to jump words. "\e[1;5C":

我的
~/.inputrc
中有以下内容:

set input-meta on
set output-meta on
set convert-meta off

# To use these in ITerm2 you may also need to configure preferences to send the correct escape
# code for the key combination.

# Option + Arrows to jump words.
"\e[1;5C": forward-word
"\e[1;5D": backward-word


# The following are other escape sequences that can be configured in Iterm2 preferences.
#        ESC ^H   Delete previous word (backspace key) [n]
#        ESC DEL  Delete previous word (delete key) [n]
#        ESC SP   Set the mark (space key); see ^X^X and ^Y above
#        ESC .    Get the last (or [n]'th) word from previous line
#        ESC ?    Show possible completions; see below
#        ESC <    Move to start of history
#        ESC >    Move to end of history
#        ESC b    Move backward a word [n]
#        ESC d    Delete word under cursor [n]
#        ESC f    Move forward a word [n]
#        ESC l    Make word lowercase [n]
#        ESC u    Make word uppercase [n]
#        ESC y    Yank back last killed text
#        ESC v    Show library version
#        ESC w    Make area up to mark yankable
#        ESC nn   Set repeat count to the number nn
#        ESC C    Read from environment variable ``_C_'', where C is
#                 an uppercase letter
有什么好处


编辑:也在iTerm2上。inputrc不是shell脚本;它是Readline库使用的配置文件,bash使用它。您可以通过键入Control-x Control-r(REE read init fileReadline函数的默认绑定)来重新读取文件

将键绑定放入
.inputrc
的好处是,任何使用Readline的程序都可以读取该文件,而不仅仅是
bash
。您可以使用
bind
命令将绑定放入
.bashrc

bind '"\e[1;5C": forward-word'

(当然,这样的绑定只在
bash
中可用)

我尝试了这个,但没有成功。我的
.inputrc
中有这些条目<代码>“\e[A”:历史向后搜索,
”\e[B”:历史向前搜索
。有时当我登录或加载终端窗口时,它们不起作用。什么不起作用?在
.inputrc
中的绑定,或在
.bashrc
中的
bind
命令中的绑定?通常,我在
.inputrc
中列出的绑定起作用。偶尔,我登录,它们不再起作用。我正在尝试要了解如何使它们在停止工作的会话中重新工作。正如您所建议的,我按了“Control+x”,然后按了“Control+r”,但没有发生任何更改,.inputrc条目仍然不工作。如果我注销并重新登录,它们仍然不工作。最终,它们将在某一天自己重新开始工作,但我会停止她现在开始工作了。我把这个问题转移到它自己的问题上,谢谢
bind '"\e[1;5C": forward-word'