If you installed OS X 10.3 from scratch, chances are your default Unix shell is bash. Those who upgraded from 10.2 (or earlier) will find that opening a new Terminal windows presents a tcsh shell instead. The shopt commands only work with the bash shell as the default, so if your default isn’t bash (the title bar reads
Terminal – tcsh
), open Terminal’s preferences, and under When Creating A New Terminal Window, select the line that reads Execute This Command (Specify Complete Path) and type
Close preferences, and from now on, each new Terminal window will open as a bash shell.
Now, in order to create or edit your .bash_profile file, open a new Terminal window and type
and press Return–this launches the Pico editor. If you’ve edited this file before, you may see previous commands in the file. If so, use the down arrow to scroll to a blank line. If the file is new, you can skip that step and just begin typing.
To add the specific example from September’s Mac OS X Hints column, add these two lines (with a Return between them):
If you feel like it, add more shortcut definitions below the websrv line (you can always come back later as well). When you’re done, type Control-O to save the file, press Return to confirm, then press Control-X to quit Pico. When you open a new Terminal window, you’ll now have your handy shortcuts ready to use. — ROB GRIFFITHS