defaults -- access the Mac OS X user defaults system aka Apple's registry
defaults [-currentHost | -host hostname] read [domain [key]]
read-type domain key
write domain { 'plist' | key 'value' }
rename domain old_key new_key
delete [domain [key]]
{ domains | find word | help }
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
Since applications do access the defaults system while they're running, 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.
User defaults belong to domains, which typically correspond to individual applications. Each
domain has a dictionary of keys and values representing 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.
read outputs all of the user's defaults, for every domain, to standard output.
> defaults read | wc
13402
> defaults read |grep mozy
"com.mozy.Config" = (
"com.mozy.Restore" = (
Name = "mozyUinMain.scpt";
Name = "mozy-1_5_2_1-8404.dmg";
"com.mozy.Config" = {
"com.mozy.Status" = {
|
read domain | outputs all of the user's defaults for domain to standard output.
|
read domain key
outputs the value for the default of domain identified by key.
> defaults read com.mozy.Config
{
BDSShowHiddenFilesKey = 1;
"NSWindow Frame BackupSetEditorWindow"="386 197 484 549 0 0 1024 746";
"NSWindow Frame ConfigurationWindow"="68 97 899 606 0 0 1024 746";
"NSWindow Frame HistoryWindow"="103 193 829 553 0 0 1024 746";
}
|
read-type domain key
| outputs the plist type for the given domain identified by key.
|
write domain key 'value'
| Writes value as the value for key in domain. value must be a property list, and
must be enclosed in single quotes. For example:
defaults write com.companyname.appname "Default Color" '(255, 0, 0)'
sets the value for Default Color to an array containing the strings 255, 0, 0
(the red, green, and blue components). Note that the key is enclosed in quotation
marks because it contains a space.
|
write domain 'plist'
| Overwrites the defaults information in domain with that given as plist. plist
must be a property list representation of a dictionary, and must be enclosed in
single quotes. For example:
defaults write com.companyname.appname '{ "Default Color" = (255, 0, 0);
"Default Font" = Helvetica; }';
erases any previous defaults for com.companyname.appname and writes the values
for the two names into the defaults system.
|
delete domain
| Removes all default information for domain.
|
delete domain key
| Removes the default named key from domain.
|
domains | outputs the names of all domains in the user's defaults system.
|
find word | Searches for word in the domain names, keys, and values of the user's defaults,
and outputs out a list of matches.
|
help |
| | | | | | | | | | | |
OPTIONS
Specifying domains:
domain | If no flag is specified, domain is a domain name of the form com.companyname.app-
name. Example:
defaults read com.apple.TextEdit
|
-app application
| The name of an application may be provided instead of a domain using the -app flag.
Example:
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 exam-
ple:
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| a string as the value for the given preference key.
| -data | a bunch of raw data bytes as the value for the given
preference key. The data must be provided in hexidecimal.
| -int[eger]| an integer as the value for the given preference key.
| -float | a floating point number as the value for the given preference key.
| -bool[ean] | a boolean as the value for the given preference key.
Value must be TRUE, FALSE, YES, or NO.
| -date | a date as the value for the given preference key.
| -array | 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 | 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 | 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| 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 created with the specified dictionary as its value.
Specifying a host for preferences:
Operations on the defaults database normally apply to any host the user may log in on, but may
be restricted to apply only to a specific host.
If no host is provided, preferences operations will apply to any host the user may
log in on.
| -currentHost
| Restricts preferences operations to the host the user is currently logged in on.
| -host hostname | Restricts preferences operations to hostname.
| | | | | | | | | | | | | | | | |
BUGS
Defaults can be structured in very complex ways, making it difficult for the user to enter
them with this command.
HISTORY
First appeared in NeXTStep.
Mac OS X Nov 3, 2003
Command line interface to a user's defaults.
'defaults' [-currentHost | -host <hostname>] followed by one of the following:
read shows all defaults
read <domain> shows defaults for given domain
read <domain> <key> shows defaults for given domain, key
read-type <domain> <key> shows the type for the given domain, key
write <domain> <domain_rep> writes domain (overwrites existing)
write <domain> <key> <value> writes key for domain
rename <domain> <old_key> <new_key> renames old_key to new_key
delete <domain> deletes domain
delete <domain> <key> deletes key in domain
domains lists all domains
find <word> lists all entries containing word
help output this help
<domain> is ( <domain_name> | -app <application_name> | -globalDomain )
or a path to a file omitting the '.plist' extension
<value> is one of:
<value_rep>
-string <string_value>
-data <hex_digits>
-int[eger] <integer_value>
-float <floating-point_value>
-bool[ean] (true | false | yes | no)
-date <date_rep>
-array <value1> <value2> ...
-array-add <value1> <value2> ...
-dict <key1> <value1> <key2> <value2> ...
-dict-add <key1> <value1> ...
Examples
defaults read com.apple.finder AppleShowAllFiles TRUE
0
defaults write com.apple.finder AppleShowAllFiles TRUE
TRUE
defaults write com.apple.mail PreferPlainText -bool TRUE
defaults write com.apple.dock no-bouncing -bool TRUE
See also, apple;Dock; Dock preferences
Well there it is folks. For all you "my Apple Mac is better than your PC"
Does Mac OS X have a registry, YES this is it. And it's just as well (or not) documented as Micro$oft's!
Apple mail defaults