我想使用交互式 posix bash shell,但自动完成功能不起作用。当我输入制表符时,它只是打印一个制表符。仅当我在非 posix 交互式 shell 或具有 emacs 输入模式的 posix 交互式 shell 上时,制表符补全才有效。我觉得 emacs 输入模式很别扭,我习惯了 vi 输入模式。仅当我处于 posix 模式和 vi 输入模式时才会出现问题,在这种情况下,制表符键仅在 shell 上打印制表符空格。另外,当我使用 sh 命令调用 bash 时,也会出现同样的问题。
这是我的 /etc/inputrc :
# do not bell on tab-completion
set bell-style audible
set meta-flag on
set input-meta on
set convert-meta off
set output-meta on
# Completed names which are symbolic links to
# directories have a slash appended.
set mark-symlinked-directories on
set editing-mode vi
set keymap vi-insert
set mark-modified-lines on
$if mode=emacs
# for linux console and RH/Debian xterm
"\e[1~": beginning-of-line
"\e[4~": end-of-line
# commented out keymappings for pgup/pgdown to reach begin/end of history
#"\e[5~": beginning-of-history
#"\e[6~": end-of-history
"\e[5~": history-search-backward
"\e[6~": history-search-forward
"\e[3~": delete-char
"\e[2~": quoted-insert
"\e[5C": forward-word
"\e[5D": backward-word
"\e[1;5C": forward-word
"\e[1;5D": backward-word
# for rxvt
"\e[8~": end-of-line
"\eOc": forward-word
"\eOd": backward-word
# for non RH/Debian xterm, can't hurt for RH/DEbian xterm
"\eOH": beginning-of-line
"\eOF": end-of-line
# for freebsd console
"\e[H": beginning-of-line
"\e[F": end-of-line
$endif
答案1
您需要显式启用vi
模式的制表符补全
"\C-i": complete
在.inputrc
。请注意,还有一个(未记录?)vi-complete
命令可能更适合vi
模式。