One of the first things that traditional Unix users will notice when
they start poking around in the Terminal is that there are a few new
commands they’ll need to add to their repertoire.
Three that we’ll discuss here are
command, used to select, examine, and define key bindings for use in
the Terminal. Table 4-13 shows the various uses of
Table 4-13. Using the bindkey command
When you customize your Mac using the System Preferences, or an
application’s preferences, all those changes and
settings are stored in what’s known as the
preferences system, and the command-line utility
to change your preferences is the
command. Everything that you’ve done to make your
Mac yours is stored as XML data in the form of a property
plist). Your property lists
are stored in
defaults command is not for the
foolhardy. If you’re not comfortable with the
command line or unsure of how to change a setting properly, you
should stick to using the application’s Preferences
pane, rather than trying to use the
If you do manage to mangle your settings, the easiest way to correct
the problem is to go back to that application’s
Preferences pane and reset your preferences. Another solution is to
delete the preferences file for the application from
Every time you change one of those settings, that particular property
list is updated. For the initiated, there are two other ways to alter
the property lists. The first is by using the Property List Editor
/Developer/Applications), and the
other is by using the
defaults command in the
Terminal. Extensive coverage of both is beyond the scope of this
book, but we’ll show you a few basic examples of how
to use the
The following are some examples of working with the defaults command:
- View all the user defaults on your system
- View the settings for your Dock
defaults read com.apple.dock
This command reads the settings from the
com.apple.dock.plistfile, found in
~/Library/Preferences. This listing is rather long, so you might want to pipe the output to
moreto view the contents one screen at a time:
defaults read com.apple.dock | more
- Change the location of your Dock to the top of the screen
orientation = bottom;
You’ll see that its value is set to
bottom, which means that your Dock is located at the bottom of the screen. To change that setting, try the following:
defaults write com.apple.dock
After a short pause, you’ll be returned to another command prompt, but you’ll notice that the Dock is still located at the bottom of the screen. Unlike some other changes you make with the defaults command, changes to the Dock will take effect only if you log out and log back in.
exit, and quit the Terminal, and then save any changes in other applications and quit them too. Now log out and log back in to your system (Apple → Log Out). When you log back in, you’ll see the Dock in all its glory floating just below the menu bar at the top of the screen. To quickly change its location back to the bottom of the screen (or the left or right side), use Apple → Dock → Position on (Left, Bottom, or Right).
For additional options and to learn more about how to use the
defaults command, enter
or view the defaults manpage (
With Mac OS X, you can launch any application from the command line
open command. There are three ways to
invoke the command:
opens the file
textFile.txtusing the default text editor, which is TextEdit.
open -a [
The -a option lets you specify the application to use when opening the file. For example, let’s say you have both Microsoft Office 2001 and Office v.X on your system and you want to open a Word file using Word 2001. If you use open
.doc, Word v.X will launch. To open the file with Word 2001, you need to do the following:
open -a /Volumes/Mac\ OS\ 9/Applications\
OS\ 9\)/Microsoft\ Office\ 2001/Microsoft\
While that might look ugly (and it is), the command does work. In this case, Classic would also launch because Word 2001 is a Classic app.
There is a shortcut for inserting long pathnames like the one shown in this example: locate the application in the Finder, and drag the application icon from the Finder window to the Terminal window after typing
open -aat the command line. The path for the application will be inserted after the command, and then you need only tack on the path and filename for the file.
open -e [
-eoption forces the use of the TextEdit application. For example:
open -e ~/Books/Templates/proposal_template.txt
Some additional examples of using the Terminal to open files and launch applications are shown here:
- Open an HTML page using a browser other than Internet Explorer?
The other way to do this is to specify the application, using the
open -a /Applications/Navigator.app
-aoption is used to launch Chimera, the Cocoa-compliant web browser, which is based on the Mozilla source code (hence its true application name, Navigator) for Mac OS X (assuming you have Chimera installed on your system, http://www.mozilla.org/projects/chimera) for viewing the
index.htmlfile, located in your Sites directory.
- Launch Classic from the Terminal?
alias classic 'open -a /System/Library/[RETURN]
CoreServices/ Classic\ Startup.app'
Now to launch the Classic environment, simply type
classicon the command line and hit return.
This assumes you’re running
tcshas the default shell. If you’re running
bash, use the following to set up the
alias classic='open -a /System/Library/[RETURN]