254

Ubuntu's Terminal uses case-sensitive auto-completion, as would be expected for Linux.

But I think sometimes it would be more convenient to use a case-insensitive one instead, to save you having to be accurate while starting a name, and would probably be worth the extra false positives. Is it possible to change this behaviour?

mwfearnley
  • 3,497

5 Answers5

322

In order to make bash case-insensitive for to current user:

Run the following shell script in a terminal:

# If ~/.inputrc doesn't exist yet: First include the original /etc/inputrc
# so it won't get overriden
if [ ! -a ~/.inputrc ]; then echo '$include /etc/inputrc' > ~/.inputrc; fi

# Add shell-option to ~/.inputrc to enable case-insensitive tab completion
echo 'set completion-ignore-case On' >> ~/.inputrc

Start a new shell (reopen the terminal).

To Make the changes systemwide:

# add option to /etc/inputrc to enable case-insensitive tab completion for all users
echo 'set completion-ignore-case On' >> /etc/inputrc
# you may have to use this instead if you are not a superuser:
echo 'set completion-ignore-case On' | sudo tee -a /etc/inputrc

For details, see man bash . Yes it is a long page, but bash is a somewhat complex program, and if you want just search that page for "case-insensitive" to go to the relevant section. People usually learn bash one option at a time or one bash script at a time and it takes a long time to master all the nuances. Your interest may vary.

Panther
  • 104,528
75

Open a terminal and type the below command:

echo set completion-ignore-case on | sudo tee -a /etc/inputrc

Enter password. Restart terminal.

If in some case you want to remove case insensitive, just edit /etc/inputrc file by removing the set completion-ignore-case line.

That's all.

regan
  • 754
emtin4
  • 1,130
38

I know this question is very old but unless I am missing something I think I have a super simple solution if you are using bash.

echo "bind 'set completion-ignore-case on'" >> ~/.bashrc

Or just add the line using your favorite text editor. Restart your bash session and enjoy.

init3
  • 389
10

You can do this by setting a configuration variable for GNU readline, which is what handles the input in an interactive shell.

The variable needed is completion-ignore-case, and can be set directly in your bash session with:

bind "set completion-ignore-case on"

It can be enabled for all future bash sessions by putting set completion-ignore-case on into the users's ~/.inputrc file, or the system /etc/inputrc, to enable it for all users. This is the initialisation file for readline.

Note that ~/.inputrc probably doesn't exist, and if you create it, your local version will override the system version at /etc/inputrc. The system version has lots of useful key mappings configured, such as Ctrl-Left/Right, and you have to link in the system version so you don't lose them.

The way to do this is to put the line $include /etc/inputrc at the top of ~/.inputrc, e.g.:

$include /etc/inputrc

set completion-ignore-case on

Once configured, you can apply the change, either by restarting bash, or reload inputrc, e.g. with Ctrlx,Ctrlr.)

More information about readline and inputrc can be found in man bash and man 3 readline.

mwfearnley
  • 3,497
0

I know that this question is old, but as I can see on ubuntu 24, the file etc/inputrc has a lot of options with descriptions.
So basically you can uncomment the sets of these lines as you prefer:

# make autocompletion case insensitive and display suggestions
# set completion-ignore-case On
# set show-all-if-ambiguous On

In my case I'm the only one using the computer so is the same to make this change globally or for my own user.

What I did to make the change for my user only, so I just copy the file this way:

cp /etc/inputrc ~/.inputrc

You can edit this file without root permissions and change whatever you want.
Is not a bad idea, after all I changed other sets and I learned a few things.

NOTE: Is a good idea to make changes to your user and not globally because you can backup your preferences in a better way or share this configuration. And in case you broke something changing the configuration, is simpler if you have to repair a user and not the OS.

Martin
  • 200