我想使用交互式 Posix bash shell,但自动完成功能不起作用。当我键入制表符时,它只会打印一个制表符。仅当我处于非 Posix shell 或具有 Emacs 输入模式的 Posix shell 中时,制表符补全才起作用。我觉得Emacs的输入模式很别扭,因为我习惯了vi
输入模式。使用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
切特·雷米说:
在POSIX模式下,vi编辑模式不应该通过映射tab来完成。这是因为 POSIX.2 完全规定了 vi 编辑模式的行为,并且标准要求 tab 默认映射到 self insert。
将以下行添加到~/.inputrc
:TAB: complete
或者您可以添加bind 'TAB: complete'
到~/.bashrc
答案2
看什么POSIX不得不说的sh- 没有提到完成。因此Tab产生一个(水平)制表符。