I’m not sure if what I’m asking is possible, but what I would like bash to do on tab presses is this:

  • On the first tab press, expand a common prefix (skip/beep and do nothing, I don’t really mind, if there isn’t one)
  • On the second tab press, list out options
  • Any subsequent tab presses cycle through these options

If any key other than tab is pressed throughout the process, then the next tab press will behave as step one.

I managed to get one and two with this:

bind “set show-all-if-unmodified on”
bind ‘set menu-complete-display-prefix on’

And I managed to get one and three with this:

bind ‘set menu-complete-display-prefix on’
bind ‘TAB:menu-complete’

Combining all three options results in one and three, however.

How can I get the desired behaviour?


  • Have you considered using zsh? I've heard it does this natively and by default, but bash can probably do it too.
    – QuickishFM
    Commented Feb 12, 2019 at 9:39

1 Answer 1


Setting these options in .inputrc is close:

set show-all-if-ambiguous on
set menu-complete-display-prefix on
TAB: menu-complete
set colored-completion-prefix on
set colored-stats on

It combines step one and two in a way that when you first press TAB it completes the common prefix and also shows the list of possible completions. Subsequent TAB presses cycle through them. I've found the "colored" options helpful so I've listed them as a bonus.

You must log in to answer this question.

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