I would like a bash autocomplete feature that would cycle through all the possibilities, like in zsh, while also doing the usual operation, which is to print all the possibilities, assuming there aren't too many, and otherwise confirm before printing.

These 2 shouldn't be mutually exclusive. I know how to make it cycle through the possibilities (bind 'TAB:menu-complete'), but it loses the first feature.

Also, I was wondering if it is possible to go backwards (something like shift+tab, as in many other software), because it's really annoying to have to do the whole loop again.

  • The easiest solution I can think of is to use zsh for zsh-like autocomplete.
    – Rob
    Apr 30 '12 at 18:57

In order to obtain this functionality you need to write the following lines to the ~/.inputrc file:

# cycle forward
Control-k: menu-complete
# cycle backward
Control-j: menu-complete-backward

This way you will keep the current Tab behaviour. There is also another configuration option you may want to consider adding:

# display one column with matches
set completion-display-width 1

It makes the possibilities displayed in one column, so instead of:

file1 file2 file3 file4...


file1  file3  ...
file2  file4

you get:


much easier on the eyes to my taste.

See man readline for more info or visit the GNU Readline Library website.

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.