Unix for Mac OS X 10.4 Tiger: Visual QuickPro Guide (2nd Edition)

Configuring Mac OS X Defaults from the Command Line

Mac OS X uses a system for storing settings called the defaults system . The defaults system stores settings such as those you make in the preferences of Mac OS X applications and the various panes (formerly called control panels ) in System Preferences.

The defaults system is one of the things that Mac OS X (or, more properly, Darwin) inherits from its NeXT ancestor . In most cases you should continue to use the GUI tools for seeing and changing these settings, but in some cases you may want (or need) to view or make changes from the command line. Figure 7.14 is an excerpt from the man page for the defaults command.

Figure 7.14. Excerpt from the man page for the defaults command.

Defaults allows users to read, write, and delete Mac OS X user defaults from a command-line shell. Mac OS X applications and other programs use the defaults system to record user preferences and other information that must be maintained when the applications aren't running (such as default font for new documents, or the position of an Info panel). Much of this information is accessible through an application's Preferences panel, but some of it isn't, such as the position of the Info panel. You can access this information with defaults Note : Since applications do access the defaults system while they're run- ning, you shouldn't modify the defaults of a running application. If you change a default in a domain that belongs to a running application, the application won't see the change and might even overwrite the default.

Mac OS X defaults are stored in files using a format called plist format (see man plist ). Each user's preferences are stored in ~/Library/Preferences inside his or her home directory. For example, your Safari Preferences are stored in ~/Library/Preferences/com.apple.Safari.plist . Systemwide defaults are stored in /Library/Preferences , so the Software Update program's settings (which are not user-specific ) are stored in /Library/Preferences/com.apple.SoftwareUpdate.plist .

Mac OS X comes with a GUI application for viewing and editing .plist files, the Property List Editor (located in /Developer/Applications/Utilities ), but here we will show you how to manipulate these files the preferred way using the defaults command.

To read preferences for an application:

Tips

To configure the Finder to display hidden files:

1.

defaults write com.apple.Finder

AppleShowAllFiles -string ON

The general form of the command is

defaults write domain key value

See man defaults for more details.

You need to restart the application (the Finder in this case) for the change to take effect.

2.

Log out of Mac OS X.

3.

Log in again.

You will see files and folders that were previously hidden, as shown in Figure 7.16 .

Figure 7.16. A Finder view of the root level of the system disk after using the defaults command to turn on AppleShowAllFiles .

You can remove the configuration change with

defaults write com.apple.Finder AppleShowAllFiles -string OFF

and then restart the Finder.

Tip

Категории