25

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 '12 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 '12 at 18:34
31
+100

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 '12 at 5:38
  • 1
    How can this easily be undone? – dingalapadum Oct 13 '15 at 8:53
  • 1
    bind "TAB:complete"; bind "set show-all-if-ambiguous off" – Jim Paris Oct 14 '15 at 13:54
  • 12
    @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 '15 at 13:00
  • 2
    @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 '16 at 21:34
0

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 '12 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 '12 at 4:46

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.