43

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
  • 19,020
  • 17
  • 95
  • 126

1 Answers1

61

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
  • 34,084
  • 5
  • 66
  • 70
  • 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 Mar 30 '15 at 18:47
  • 1
    You can also use [bind -f ~/.inputrc](http://superuser.com/a/1064223/362931) 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 05 '17 at 02:34
  • Strangely, it doesn't work for me. Here's my `~/.inputrc`: https://pastebin.com/WVQmrNZu – Aleksei Petrenko Jan 08 '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