Bash

bash inputrc 不會載入

  • December 16, 2020

我創建了 ~/.inputrc 並且在 bash readline 上看不到它的任何效果。

$ bind -f ~/.inputrc不顯示錯誤也不載入文件。

$INPUTRC 未設置,如果我export INPUTRC=~/.inputrc在 ~/.bashrc 中並重新啟動 bash,則沒有任何變化。

$ strace bash在驗證讀取發生的輸出中搜尋 inputrc :

openat(AT_FDCWD, "/home/me/.inputrc", O_RDONLY) = 3
fstat(3, {st_mode=S_IFREG|0664, st_size=1900, ...}) = 0
read(3, "# ~/.inputrc\n#\n# bash configurat"..., 1900) = 1900
close(3)                                = 0

我的 .inputrc 打開的輸出$ bind -v | grep completion-ignore-case,但 bind 顯示它仍然關閉:

設置完成忽略大小寫

的輸出$ bind -p | grep -e C-q應該顯示我的 .inputrc 重新定義了 control-q,但 bind 顯示:

“\Cq”: 引用-插入

我的 inputrc 文件:

# ~/.inputrc
#
# bash configuration file
# See readline(3readline) and `info rluserman' (readline llibrary) for more information.
#
# set VARIABLE VALUE
# KEY-NAME: "MACRO"
# KEY-NAME: COMMAND
#
# Note: Keystrokes like \015 or \C-m (return) may be part of MACRO
#
# \C-KEY = Control-KEY (KEY should be lower case)
# \M-KEY = Alternate-KEY (KEY should be lower case)
# \e = escape (sent by keyboard when using alternate key)
# \\ = backslash
# \" = double quote
# \' = single quote
# \a = altert bell
# \b = backspace
# \d = delete
# \f = form feed
# \n = newline (linux: line feed \x0A)
# \r = return
# \t = tab
# \v = vertical tab
# \ooo = 8 bit octal code
# \xHH = 8 bit hex codep
#
# $if
# $else
# $endif
# $include

###############
# stuff from /etc/inputrc
###############

# Be 8 bit clean.
set input-meta on
set output-meta on

# arrow key bindings
"\e[A": history-search-backward
"\e[B": history-search-forward
"\e[C": forward-char
"\e[D": backward-char

# allow the use of the Home/End keys
"\e[1~": beginning-of-line
"\e[4~": end-of-line

# allow the use of the Delete/Insert keys
"\e[3~": delete-char
"\e[2~": quoted-insert

# alternate mappings for "page up" and "page down" to search the history
# "\e[5~": history-search-backward
# "\e[6~": history-search-forward

# mappings for Ctrl-left-arrow and Ctrl-right-arrow for word moving
"\e[1;5C": forward-word
"\e[1;5D": backward-word
"\e[5C": forward-word
"\e[5D": backward-word
"\e\e[C": forward-word
"\e\e[D": backward-word

$if term=rxvt
"\e[7~": beginning-of-line
"\e[8~": end-of-line
"\eOc": forward-word
"\eOd": backward-word

###############
# my stuff
###############

set colored-stats on
set completion-ignore-case on
set completion-prefix-display-length 3
set mark-symlinked-directories on
set show-all-if-ambiguous on
set show-all-if-unmodified on
set visible-stats on

# Convert line to $"(..)"
"\C-q": "\C-a\"$(\C-e)\"\C-a"

我的.inputrc文件包含一個$if但缺少一個$endif導致內容被忽略的內容。

引用自:https://unix.stackexchange.com/questions/624772