3

I would like to use an interactive Posix bash shell but the autocomplete feature doesn't work. When I type the Tab character it simply prints a tab. The tab completion works only when I'm in a non-Posix shell or in a Posix shell with Emacs input mode. I find Emacs input mode very awkward, as I am used to vi input mode. Invoking bash with the sh command doesn't help.

Here is my /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
  • Of course it's well documented that invoking bash as sh makes it act more like the Bourne shell, which was developed in 1977 — i.e., much less capable. – G-Man Says 'Reinstate Monica' Jun 28 '15 at 3:59
3

Chet Ramey says:

in POSIX mode, the vi editing mode should not map tab to complete. This is because POSIX.2 completely specifies the behavior of the vi editing mode, and the standard requires tab to be mapped to self insert by default.

Add the following line to ~/.inputrc: TAB: complete

Or you can add bind 'TAB: complete' to ~/.bashrc

1

See what POSIX has to say about sh - no mention of completion. Hence Tab produces a (horizontal) tab character.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.