41

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?

  • I'm glad to know that this works on Linux, as the other question is OSX-specific, @sathya – earthmeLon Nov 18 '14 at 22:02
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.

  • 14
    This 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 Mar 30 '15 at 18:47
  • 1
    You can also use bind -f ~/.inputrc to reload this change. – bishop Apr 12 '16 at 13:31
  • 2
    I'm going to incorporate @NicolasMarchildon comment into the answer, because it should be there – theEpsilon Jan 5 '17 at 2:34
  • Strangely, it doesn't work for me. Here's my ~/.inputrc: pastebin.com/WVQmrNZu – Aleksei Petrenko Jan 8 '18 at 13:24
  • @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 Jan 10 '18 at 19:11

Not the answer you're looking for? Browse other questions tagged or ask your own question.