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.

  • 3
    It's been a while since I have used ZSH, but I believe its autocomplete functions like this.
    – jordanm
    Nov 8, 2012 at 18:07
  • 1
    @jordanm Well seems like an option if nothing else works, but that would also entail updating everything from .bashrc, etc. to the ZSH equivalents, which I'd quite like to avoid.
    – Voo
    Nov 8, 2012 at 18:34

3 Answers 3


This seems close to what you want:

bind "TAB:menu-complete"
bind "set show-all-if-ambiguous on"
  • 1
    Almost perfect, apart from the small flaw that it also autocompletes on the first tab, which can be a bit annoying if I'm just trying to figure out the exact name (i.e. I have to delete quite a bit more characters if I want to change then), but I'm quite willing to live with that.
    – Voo
    Nov 14, 2012 at 5:38
  • 1
    How can this easily be undone? Oct 13, 2015 at 8:53
  • 1
    bind "TAB:complete"; bind "set show-all-if-ambiguous off"
    – Jim Paris
    Oct 14, 2015 at 13:54
  • 19
    @Voo add the third line bind "set menu-complete-display-prefix on" will just list the candidates on the first tab without auto-completion.
    – Naitree
    Nov 17, 2015 at 13:00
  • 3
    @Naitree can't upvote your suggestion enough. It works and IS so, so much better than the default bash behavior. Thank you.
    – JBeurer
    Dec 6, 2016 at 21:34

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

  • This is seriously the best user experience I've ever had. Thank you!
    – Tom
    Feb 15, 2020 at 3:45

Have you considered? It was referenced at Superuser ...

[[ $- = *i* ]] && bind TAB:menu-complete
  • 1
    menu-complete is only half of what the question is asking. As the question says, "[b]oth options are easy to do separately".
    – jw013
    Nov 8, 2012 at 19:18
  • Yes I know how to change the behavior to one of the two options, but that's the easy part. The real problem is how to combine the two into one.
    – Voo
    Nov 10, 2012 at 4:46
  • Can you explain to me the detail of what's going on in that line?
    – Tom
    Feb 15, 2020 at 1:49

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.