Ignore case with Teminal tab completion

When you run Terminal in OS X 10.3 or 10.4, you’re working with something called the bash shell (in 10.2 and earlier, Terminal used the tcsh shell ). Both bash and tcsh feature something called tab completion—start typing a command or directory path, press Tab, and the shell will do its best to complete things for you. For instance, if I want to change to the system-level directory that holds the default Apache webserver pages, I could simply type cd /Li[Tab]/We[Tab]/Do[Tab]. Each time I hit Tab, the shell will complete the remainder of the word that I’ve typed, assuming it can find a match. In this example, the command line would read cd /Library/WebServer/Documents after my three presses of the Tab key.

The one annoyance about this feature is that it is, by default, case sensitive. So I have to type the case of the letters as shown above, otherwise no matches will be found when I press the Tab key. Most typists, myself included, find that having to capitalize letters slows down one’s typing speed, and adds wear and tear (“excess finger presses”) to one’s hands. Thankfully, it’s easy to change the shell’s behavior to ignore capitalization.

If you’re running 10.3 or 10.4, just execute this command in Terminal:

echo "set completion-ignore-case On" >> ~/.inputrc

This command is actually creating (or adding to) a file in your user’s home directory named .inputrc. The double greater-than signs route the output of the echo command into that file (by using two greater than signs, the new line will be appended to an existing file; if only one greater than sign were used, the entire file would be overwritten). And exactly what is the echo command echoing? It’s the command to set a bash variable to ignore letter case when calculating auto-completion.

After running the above command, open a new Terminal window and try typing cd /li[Tab]/we[Tab]/do[Tab]. Each time you press Tab, you’ll see that the lower case letters are replaced by their upper case versions, based on where the shell finds a match (i.e. /li becomes /Li, etc.).

If you’re running 10.2 or earlier (or using the tcsh shell in 10.3 or 10.4), then you’ll need this command:

echo "set complete = enhance" >>  ~/.tcshrc

The end result in either bash or tcsh is the same: capitalization is no longer required for auto-completion. Let your fingers fly at full speed, without the need to slow down for the occasional capital letter! If you ever wish to undo this change, it’s fairly simple. In bash, repeat the above command, but change On to Off. In tcsh, remove the = enhance bit of the command, leaving just set complete. Open a new Terminal window in either shell after running the revised commands, and you should find that case once again matters for auto-completion.

Shop Tech Products at Amazon