Bash autocomplete: first list files then cycle through them

Is it possible to configure bash in such a way that on the first tab autocomplete it lists all possible files and on subsequent ones cycles through the choices?

Both options are easy to do separately and I could bind them to different keys, but the above would be perfect, but I can’t find anything about it on the net.

Asked By: Voo

||

Have you considered? It was referenced at Superuser …

[[ $- = *i* ]] && bind TAB:menu-complete
Answered By: tink

This seems close to what you want:

bind "TAB:menu-complete"
bind "set show-all-if-ambiguous on"
Answered By: Jim Paris

This is what I use. As far as I can tell it does exactly what you want.

# make tab cycle through commands after listing
bind '"t":menu-complete'
bind "set show-all-if-ambiguous on"
bind "set completion-ignore-case on"
bind "set menu-complete-display-prefix on"

This works on Mac (10.13 & 10.14) and Ubuntu (16.04 & 18.04).

Answered By: Milo
Categories: Answers Tags: ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.