defaults

Set preferences, the OS X user defaults system works with both the OS and with individual applications.

Syntax
      defaults [host] Actions Options

      defaults help

Actions:
   read [domain [key]]      Print defaults to standard output

   read-type domain key     Print the plist type

   write domain key 'value' Save a default value

   write domain 'plist'     Save plist (a property list) as a default:

   rename domain old_key new_key  Rename a domain key.

   delete [domain [key]]    Remove key.
                            (for most applications this will return the behaviour
                             to the original default values) 
 
   domains                  Print all the domains in the user's defaults system.

   defaults [host] find word 
                            Search for word in the user's defaults, and
                            print a list of matches.

   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.

Options: See below

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:

Monitor font smoothing

Display the current font smoothing:
$ defaults -currentHost read -globalDomain AppleFontSmoothing

Change the font smoothing (
0=off, 1=light, 2=Medium/flat panel, 3=strong/blurred)
$
defaults -currentHost write -globalDomain AppleFontSmoothing -int 0
Restart applications to see the effect

Delete the setting completely (restore default)
$
defaults -currentHost delete -globalDomain AppleFontSmoothing

iTunes 10

Make the arrows next to artist & album jump to local iTunes library folders instead of Store
$
defaults write com.apple.iTunes show-store-link-arrows -bool YES
$ defaults write com.apple.iTunes invertStoreLinks -bool YES
To restore the default change the YES to NO

Restore the standard close/minimise buttons
$
defaults write com.apple.iTunes full-window -1

Hide the iTunes Genre list
$
defaults write com.apple.iTunes show-genre-when-browsing -bool FALSE

Finder

Show hidden files
$
defaults write com.apple.finder AppleShowAllFiles TRUE
$
killall Finder

Hide hidden files (default)
$
defaults write com.apple.finder AppleShowAllFiles FALSE
$
killall Finder

Disable the OS X Crash reporter (quit dialog after an application crash)
$
defaults write com.apple.CrashReporter DialogType none
To enable the crash reporter (default) change none to prompt

Disable dashboard widgets (saves RAM)
$
defaults write com.apple.dashboard mcx-disabled -boolean YES
To Enable dashboard widgets (default) set this to NO

Disable the New Window Animation in OS X Lion
$ defaults write NSGlobalDomain NSAutomaticWindowAnimationsEnabled -bool NO
To enable the animation (default) set this to YES

Dock

Two Dimensional Dock (disable the 3D mirror glass effect)
$
defaults write com.apple.dock no-glass -bool YES
$ killall Dock

Three Dimensional Dock (default)
$
defaults write com.apple.dock no-glass -bool NO
$ killall Dock

Disable Bouncing dock icons
$
defaults write com.apple.dock no-bouncing -bool True
$ killall Dock
To re-enable, set this back to False

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"; }'
$ killall Dock
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"

Stacks, Activate Mouse Over Gradient:
$
defaults write com.apple.dock mouse-over-hilte-stack -boolean YES
$ killall Dock
To deactivate set back to NO

Terminal/other

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

Force all Apple Mail messages to display as plain text.
$
defaults write com.apple.mail PreferPlainText -bool TRUE
For rich text (the default) set it to 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.

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:

defaults man page - Apple.com
Long list of OS X and App defaults from Mathias Bynens (+ older fork github)
secrets.blacktree.com - Another extensive list of defaults
Show hidden files.scpt - Toggle the display of hidden files in Finder (will restart finder)



Back to the Top

© Copyright SS64.com 1999-2013
Some rights reserved