Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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.

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

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

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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