Using the Linux terminal is a fantastic thing. It gives you access to hundreds of great commands and programs, can make navigating through complex directories quick and easy, and offers tools like tab auto-complete that make doing all this a breeze. However, there is a caveat for some people: Linux is case-sensitive. Personally, I love how Linux is case-sensitive, but I know that not everyone will agree with me.
There are ways to create case-insensitive partitions, but doing this has its own technical and functional limitations. If anyone is interested, drop me a line, and I’ll work on a post on this topic.
For those that don’t like how everything in Terminal is case-sensitive, there is a solution that will relieve some of the pain. You can configure your system to make tab auto-complete case-insensitive even on a case-sensitive file system.
Before detailing how to make the change, I do have to make sure that you understand that this is a system-wide setting and will not be limited to just your user. So, if you share the system with other people, you will want to run this by them first to make sure that they are on board with the change.
This change is not permanent. If you would like to try it out and don’t like it, the change is easily reversed.
Note: My instructions are specific to Ubuntu; however, this process will work on most distros with little or no modification.
The first thing we need to do is open up Terminal (Applications > Accessories > Terminal).
Create a Backup
We’re going to make modifications to the /etc/inputrc file. In order to protect ourselves from destroying the file and to make it easy to revert back to a case-sensitive auto-complete, we need to backup the file:
sudo cp -p /etc/inputrc /etc/inputrc.bak
Now if you need to restore the original file, you can simply run the following command to restore the file from the backup:
sudo cp /etc/inputrc.bak /etc/inputrc
After opening a new Terminal window, the behavior will return to the way it was before.
Modify /etc/inputrc
There are a variety of ways to make this modification. Since I don’t know what editors you have or have not used, I’m going to provide a set of instructions that anyone can execute as is without having to know how to use vim, nano, Emacs, or any of the other editors.
We first need to change our user to root:
sudo su
Note: Your prompt will change after running this command. The familiar ‘$’ is now a ‘#’. This is to remind you that you are now the root user. Being root gives you full access to do anything without the system asking for confirmation. Delete a file, and it’s gone, no questions asked. So make sure that you do not go through and start changing or removing things if you don’t know what you’re doing while having root access.
echo "set completion-ignore-case on" >> /etc/inputrc exit
The first command makes the change while “exit” exists out of root access, restoring your original prompt.
Test the Change
Open up a new Terminal window and try using the tab auto-complete. A good way to do this is to make sure that you are in your home directory (cd ~) and type “cd de<tab><tab>”. If the change has worked, this should either auto-complete to “Desktop” or show a list of possible options that includes “Desktop”.
Reversing the Change
As mentioned before, you can restore the original /etc/inputrc file by running the following:
sudo cp /etc/inputrc.bak /etc/inputrc
Did I help you?
Awesome trick! Thanks for the help, that’ll save lots of minor headaches…
[…] http://chrisjean.com/2009/02/08/case-insensitive-tabbing-in-ubuntu-terminal/ Leave a Comment TrackBack URI […]
I know this is a really old article, but I thought I’d point out that you can/should put this in ~/.inputrc instead of /etc/inputrc
The .inputrc file will be processed _after_ the /etc/inputrc when you login to the terminal. This also keeps the change local to just your user account, and won’t affect other users you may have configured on that machine. In this case you don’t have to use the sudo command to create/change the file.
Cheers,
Thanks for showing the alternate way of setting this up. For me, I set up features such as these in global configs to keep a consistent baseline of functionality and features across all users.
nice one, thanx.
a little caveat for me was ‘exit’, exit dropped me out of root, but i had to call it a second time to close the terminal then reopen it for the change to become active.