18

As most people here know, when using bash at the command prompt if you partially type a file name a command or an option to a command etc, bash will complete the word if there is exactly one match.
When there is more than one match, you need to hit <Tab> twice and bash will generate a list of possible matches.
I would like to configure bash to simply provide those options on the first <Tab>.
Is this possible without writing a script? i.e. a shell option?

man bash has a section "programmable completion" but I couldn't make out if there is an option to enable "single tab completion".

1

2 Answers 2

23

Put this in your ~/.inputrc:

set show-all-if-ambiguous on

For additional credit, add:

set completion-ignore-case on

All of the options are in the GNU manual...

2
  • 4
    Heads up: putting this in your ~/.bash_profile won't work. It has to go in your ~/.inputrc
    – yndolok
    Commented Sep 26, 2017 at 19:13
  • 7
    No kidding... That's why I specified placing it there.
    – jasonwryan
    Commented Sep 26, 2017 at 19:38
14

I do not have enough reputation to comment, but I would add to jasonwryans answers that it can be added to .bash_profile or .bashrc by writing them as:

bind 'set show-all-if-ambiguous on'
bind 'set completion-ignore-case on'

I case anybody else finds this question as I did.

You must log in to answer this question.

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