Shell Hints

Since the shell is where you spend much of your Terminal time, it’s just good horse sense to have a shell that works efficiently. The following hints are all tips for maximizing bash.

Nixing Case-Sensitivity in Autocompletion

To amp up your efficiency in Terminal, use the autocomplete feature described in Section 15.2.5. Instead of typing cd /Library/WebServer/Documents, you only have to type cd /L W D. Ha...mere kid’s play! (Just remember to press Tab after each letter to make Terminal complete the missing portions for you.)

While this feature is quite convenient, the shell is picky about what it autocompletes. For instance, if you improperly capitalize any portion of what you type, you’ll get a beep instead of a completed path. Hey, what can you do? The shell is case-sensitive.

To fix this, simply add the following line to the .inputrc file in your Home folder:

set completion-ignore-case On

Note

You need to set this variable in the .inputrc file, rather than, say, your .bash_profile file, since the autocomplete feature is part of the readline library, not the shell itself.

To return to case-sensitive behavior (for whatever reason), simply delete that line in your .inputrc file and launch a new session with bash.

Finding Files in the Current Directory

While locate is a super tool for searching your entire hard drive (hint Section 15.6.5), it can be cumbersome for more focused searches. To restrict locate to a certain directory, you must include the full path as part of the ...

Get Mac OS X Power Hound, Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.