Provides access to the Mac OS X user defaults system.
Syntax
Print defaults to standard output:
defaults [host] read [domain [key]]
Print the plist type:
defaults [host] read-type domain key
Save a default value:
defaults [host] write domain key 'value'
Save plist (a property list) as a default:
defaults [host] write domain 'plist'
Rename a domain key:
defaults [host] rename domain old_key new_key
Remove default information:
defaults [host] delete [domain [key]]
Print all the domains in the user's defaults system:
defaults [host] domains
Search for word in the user's defaults, and print a list of matches:
defaults [host] find word
Help:
defaults help
Host Optionally you may restrict changes to a specific host
by default changes will apply to any host
[-host hostname] Restrict to a remote machine.
[-currentHost] Restrict to the host the user is currently logged into.
If you change a default that belongs to a running application, the application won't see the change and might even overwrite the default.
In general you should close an application before changing its defaults, in the case of Dock and Finder defaults - restart them after applying the default with the killall command : Restart the Dock: killall Dock Restart the Finder: killall Finder
Examples
Disable the OS X Crash reporter (quit dialog after an application crash) defaults write com.apple.CrashReporter DialogType none Enable the OS X Crash reporter (default) defaults write com.apple.CrashReporter DialogType prompt iTunes - arrow next to artist/album will jump to local iTunes library defaults write com.apple.iTunes invertStoreLinks -bool YES iTunes - arrow next to artist/album will jump to the iTunes store (default) defaults write com.apple.iTunes invertStoreLinks -bool NO Force all mail to display as plain text. defaults write com.apple.mail PreferPlainText -bool TRUE Force all mail to display as rich text (default). defaults write com.apple.mail PreferPlainText -bool FALSE
Disable dashboard widgets (saves RAM) defaults write com.apple.dashboard mcx-disabled -boolean YES Enable dashboard widgets (default) defaults write com.apple.dashboard mcx-disabled -boolean NO Disable the docks 3D mirror glass effect defaults write com.apple.dock no-glass -bool YES Enable the docks 3D mirror glass effect defaults write com.apple.dock no-glass -bool NO Disable Bouncing dock icons defaults write com.apple.dock no-bouncing -bool true Enable bouncing dock icons (default) defaults write com.apple.dock no-bouncing -bool false Terminal windows take focus with mouse over window defaults write com.apple.terminal FocusFollowsMouse -string YES Terminal windows take focus with click (default) defaults write com.apple.terminal FocusFollowsMouse -string NO Add a 'Recent Applications' stack to the Dock. defaults write com.apple.dock persistent-others -array-add '{ "tile-data" = { "list-type" = 1; }; "tile-type" = "recents-tile"; }' To remove - just drag out of the dock again Change login screen background sudo defaults write /Library/Preferences/com.apple.loginwindow DesktopPicture "/Library/Desktop Pictures/Aqua Blue.jpg" Show hidden files in the finder. defaults write com.apple.finder AppleShowAllFiles TRUE Hide hidden files in the finder (default) defaults write com.apple.finder AppleShowAllFiles FALSE Options: Specifying domains: domain A full domain name of the form com.companyname.appname. defaults read com.apple.TextEdit -app application The name of an application: defaults read -app TextEdit filepath Domains may also be specified as a path to an arbitrary plist file, omitting the '.plist' extension. For example: defaults read ~/Library/Preferences/com.apple.TextEdit normally gives the same result as the two previous examples. In the following example: defaults write ~/Desktop/TestFile foo bar will write the key 'foo' with the value 'bar' into the plist file 'TestFile.plist' that is on the user's desktop. If the file does not exist, it will be created. If it does exist, the key-value pair will be added, overwriting the value of 'foo' if it already existed. WARNING: The defaults command will be changed in an upcoming major release to only operate on preferences domains. General plist manipulation utilities will be folded into a different command-line program. -g | -globalDomain | NSGlobalDomain Specify the global domain. '-g' and '-globalDomain' may be used as synonyms for NSGlobalDomain. Specifying value types for preference keys: If no type flag is provided, defaults will assume the value is a string. For best results, use one of the type flags, listed below. -string Allows the user to specify a string as the value for the given preference key. -data Allows the user to specify a bunch of raw data bytes as the value for the given preference key. The data must be provided in hexadecimal. -int[eger] Allows the user to specify an integer as the value for the given preference key. -float Allows the user to specify a floating point number as the value for the given preference key. -bool[ean] Allows the user to specify a boolean as the value for the given preference key. Value must be TRUE, FALSE, YES, or NO. -date Allows the user to specify a date as the value for the given preference key. -array Allows the user to specify an array as the value for the given preference key: defaults write somedomain preferenceKey -array element1 element2 element3 The specified array overwrites the value of the key if the key was present at the time of the write. If the key was not present, it is created with the new value. -array-add Allows the user to add new elements to the end of an array for a key which has an array as its value. Usage is the same as -array above. If the key was not present, it is created with the specified array as its value. -dict Allows the user to add a dictionary to the defaults database for a domain. Keys and values are specified in order: defaults write somedomain preferenceKey -dict key1 value1 key2 value2 The specified dictionary overwrites the value of the key if the key was present at the time of the write. If the key was not present, it is created with the new value. -dict-add Allows the user to add new key/value pairs to a dictionary for a key which has a dictionary as its value. Usage is the same as -dict above. If the key was not present, it is cre-ated created ated with the specified dictionary as its value.
Description
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.
User defaults belong to domains, which typically correspond to individual applications. Each domain has a dictionary of keys and values represent-ing representing ing its defaults; for example, "Default Font" = "Helvetica". Keys are always strings, but values can be complex data structures comprising arrays, dictionaries, strings, and binary data. These data structures are stored as XML Property Lists.
Though all applications, system services, and other programs have their own domains, they also share a domain named NSGlobalDomain. If a default isn't specified in the application's domain, but is specified in NSGlobalDomain, then the application uses the value in that domain.
A property list (or plist) can contain multiple values
e.g. to write a single value:
defaults write com.ss64.myapp "Default Color" '(255, 0, 0)'
to write two values (plist)
defaults write com.ss64.myapp '{ "Default Color" = (255, 0, 0);
"Default Font" = Helvetica; }';
BUGS
Defaults can be structured in very complex ways, making it difficult for
the user to enter them with this command.
"I am a leader by default, only because nature does not allow a vacuum" ~ Desmond Tutu
Related:
Equivalent Windows command:
regedit - Registry editor