Tab completion, part 2
If you're new here, you may want to subscribe to my RSS feed.
In the last post we discussed how tab completion makes typing Unix commands much easier. The downside, as Janssen pointed out, is that tab completion is case-sensitive, so typing cd doc and hitting tab won’t complete cd Documents/. But there’s a way to change this.
In your home folder you’ll find a file called .profile that contains settings for working in the bash shell (which is what you do every time you use Terminal.) It’s sort of the “preferences” file for the command line. The .profile file can do a lot of things, one of which is making tab completion case-insensitive. (We’ll cover more uses of .profile later.)
Because .profile begins with a dot, it’s invisible to most Mac OS X applications. A notable exception is Smultron, a free text editor that has an “Open Hidden” option. You can either use Smultron to open .profile in your home folder, or open Terminal and type open .profile, which should open the file in Apple’s TextEdit. If you don’t have this file, you’ll just create a new empty file by the same name and save it.
The line you’ll add to .profile is the following:
bind "set completion-ignore-case on"
If your .profile contains other text, simply put this at the end on its own line. If you’re creating .profile from scratch, this is the only line you’ll need. Save and close .profile.
After closing and reopening Terminal, your tab completion should now be case-insensitive. If you type cd doc and hit tab, it should fill in cd Documents/.

November 9th, 2006 at 12:29 pm
This whole article assumes you haven’t changed your default login shell to tcsh (which i always do). You might want to at least mention this in passing.
For tcsh, you want to use ” set complete=enhance” to allow case-insensitivity. Also, it causes periods, hyphens and underscores to be word separators. This means if you have files called “a-very-long-name.txt” and “a_very_long_name.html’ you can type a.txt and hit tab to get the first one (assuming there are no other files that start with ‘a’)..
November 13th, 2006 at 11:24 am
Reid: You’re right; I’m assuming people haven’t switched from bash to another shell, but I think that’s a fair assumption since bash is the default shell on every Mac, and I’ve never discussed how to change it here. This site assumes no prior Unix knowledge, so I wouldn’t want to overwhelm people with options that don’t apply to them. Eventually I want to cover advanced topics like changing the shell and then it will be important to explain the differences but until then I want to keep it simple.
Thanks for your comment and your tip about tcsh. I’ve always used bash so I didn’t know that.
November 16th, 2006 at 12:22 pm
hey just wondering when the next is likey to happen thanks
November 16th, 2006 at 12:22 pm
sorry next post is likey to happen