0

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.

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

1 Answer 1

1

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...

or

file1  file3  ...
file2  file4

you get:

file1
file2
file3
file4
...

much easier on the eyes to my taste.

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

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .