defaults (software)

From Wikipedia, the free encyclopedia
Jump to navigation Jump to search

defaults is a command line utility that manipulates plist files. defaults is present in the macOS[1] and GNUstep operating systems, and first appeared in the NeXTSTEP operating system upon which both aforementioned systems are based. The system stores each user's preferences set in a .plist file for each program stored at ~/Library/Preferences for user-specific preferences, and /Library/Preferences/ for global preferences. defaults writes to or reads from these plist files depending on the domain given.

An advantage of the defaults system is its ability to store data in a variety of formats: integer, character string, floating point, binary data, dates, so-called dictionaries, or arrays of the same.

Previous versions also offered the opportunity of direct disk access.[clarification needed]


Common uses of defaults:

$ defaults read DOMAIN # gets all
$ defaults read DOMAIN PROPERTY_NAME # gets
$ defaults write DOMAIN PROPERTY_NAME $VALUE # sets
$ defaults delete DOMAIN PROPERTY_NAME # resets a property
$ defaults delete DOMAIN # resets preferences

DOMAIN should be replaced by the plist file sans extension ('.plist'). plist files are named with reverse domain name notation. For example:

$ defaults read # prints all iTunes preference values

plist files store keys and values. The PROPERTY_NAME key is the name of the property to modify. For example, to remove the search field from Safari's address bar:

$ defaults write AddressBarIncludesGoogle 0


$ defaults write AddressBarIncludesGoogle -bool NO # case-sensitive!

Replacing 0 with 1 or NO with YES or FALSE with TRUE returns the search bar to normal.

Preferences can at times corrupt applications. To reset Address Book's preferences, either the file ~/Library/Preferences/ must be removed or the following command issued:

$ defaults delete


Some example settings configurable with defaults.

Domain Value OSX Version Legal Values Default Values
NSGlobalDomain AppleAquaColorVariant 10.8 1, 6 1
NSGlobalDomain AppleHighlightColor 10.8 3 floats range 0-1.0 "0.780400 0.815700 0.858800"
NSGlobalDomain AppleShowScrollBars 10.8 Automatic, WhenScrolling, Always Automatic
NSGlobalDomain NSQuitAlwaysKeepsWindows 10.8 bool false
NSGlobalDomain NSAutomaticWindowAnimationsEnabled 10.8 bool true
NSGlobalDomain NSNavPanelExpandedStateForSaveMode 10.8 bool false
NSGlobalDomain NSWindowResizeTime 10.8 float:time in seconds .2