Make bash's tab-completion case-insensitive

41

10

Possible Duplicate:
Case insensitive tab completion in Bash

Is there any way to make the tab-completion in bash case-insensitive? For instance, if I have a file called Hello.txt and try to tab-complete it by typing he followed by Tab it will not work. I would have to tab-complete it by typing He (note the capital H) and Tab. Is there any way to set up bash so I don't have to preserve the case when I type it and try to tab-complete it?

Wuffers

Posted 2011-04-16T03:26:02.547

Reputation: 16 645

Question was closed 2011-04-16T03:45:19.603

I'm glad to know that this works on Linux, as the other question is OSX-specific, @sathya – earthmeLon – 2014-11-18T22:02:06.623

Answers

57

Create a file named .inputrc in your home directory, and place this line in it:

set completion-ignore-case on

Then open a new shell and try it out. If /etc/inputrc exists on your system, you should generally also add the line $include /etc/inputrc. But there's no way to make this conditional, so you should only add it if that file exists.

Gordon Davisson

Posted 2011-04-16T03:26:02.547

Reputation: 28 538

14This will prevent bash from reading the defaults from /etc/inputrc, breaking things like navigation with ctrl-left/right. Make sure to add $include /etc/inputrc in your ~/.inputrc. – Nicolas Marchildon – 2015-03-30T18:47:39.750

1

You can also use bind -f ~/.inputrc to reload this change.

– bishop – 2016-04-12T13:31:41.790

2I'm going to incorporate @NicolasMarchildon comment into the answer, because it should be there – theEpsilon – 2017-01-05T02:34:02.603

Strangely, it doesn't work for me. Here's my ~/.inputrc: https://pastebin.com/WVQmrNZu

– Aleksei Petrenko – 2018-01-08T13:24:02.030

@AlexeyPetrenko That looks ok to me. Are there any invisible characters in the file messing things up? Try printing it with LC_ALL=C cat -vet ~/.inputrc -- you should see a "$" at the end of each line, but nothing else funny. Also, try bind -v, and see what it shows for the completion-ignore-case variable. Finally, is there something in another shell init file that might be changing it? – Gordon Davisson – 2018-01-10T19:11:53.383