Unix for Mac OS X 10.4 Tiger: Visual QuickPro Guide (2nd Edition)
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:
- defaults read domain
The domain value is in the format domain.company.Application .
The domain for the Finder is com.apple.Finder , and for the Firefox Web browser it's org.mozilla.firefox .
For example, to read your settings for the Finder, you would run
defaults read com.apple.Finder
which produces output like that shown in Figure 7.15 .
Figure 7.15. Using the defaults command to show your Finder settings. (Output is abbreviated.)
{ ComputerOptions = { ComputerBackgroundType = DefB; ComputerIconViewArrangeBy = dnam; ComputerIconViewIconSize = 64; ComputerIconViewScrollPosition = {h = 0; v = 0; }; ComputerListViewColumnFlags = 1; ComputerScrollPosition = {h = 0; v = 0; }; ComputerToolbarVisible = 1; ComputerUseCustomIconViewOptions = 1; ComputerUseCustomListViewOptions = 1; ComputerViewStyle = icnv; }; CopyProgressWindowLocation = "397, 51"; EmptyTrashProgressWindowLocation = "457, 51"; . . . (output truncated for space)
-
There can be a great deal of output, so you might want to pipe the output through less :
defaults read com.apple.Finder less
-
You can get a list of all the available domain values with
defaults domains
The output will be a (long) comma-separated list of domains for which you have defaults.
To configure the Finder to display hidden files:
| 1. | defaults write com.apple.Finder
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 and then restart the Finder.
|
-
Some longtime Unix users prefer to have "focus follows mouse" on their Terminal windows . As soon as the cursor moves over the window, whatever you type goes to that window, without your having to click it or bring it to the front. This behavior is the default in some graphical interfaces for Unix. You can use the defaults command to make the Terminal application behave this way:
defaults write com.apple.Terminal
FocusFollowsMouse -string YES and turn it off with
defaults write com.apple.Terminal
FocusFollowsMouse -string NO You need to restart Terminal for the change to take effect.
Категории