Defaults (software)

{{Distinguish|text=the generic computer science concept of defaults}}

{{Short description|Command-line utility}}

{{notability|date=December 2016}}

{{primary sources|date=December 2016}}

{{lowercase|title=defaults}}

defaults is a command line utility that manipulates plist files. Introduced in 1998 OPENSTEP, defaults is found in the system's descendants macOS and GNUstep.{{man|1|defaults|ManKier}}{{man|1|defaults|Darwin}}

The name "defaults" derives from OpenStep's name for user preferences, Defaults, or NSUserDefaults in Foundation Kit. Each application had its own defaults plist ("domain"), under {{tt|~/Defaults}} for the user configuration and {{tt|/Defaults}} for the system configuration. The lookup system also supports a {{tt|NSGlobalDomain.plist}}, where defaults written there will be seen by all applications.{{Cite web |title=User Defaults Summary for GNUstep Libraries |url=http://www.gnustep.org/resources/documentation/User/Gui/DefaultsSummary.html |website=www.gnustep.org}} In macOS, the {{tt|Defaults}} part of the path is replaced by the more intuitive {{tt|Library/Preferences}}. defaults accesses the plists based on the domain given.

defaults is also able to read and write any plist specified with a path, although Apple plans to phase out this utility in a future version.{{Cite web |title=Unofficial macOS defaults man page |url=https://ss64.com/osx/defaults.html |website=ss64.com}}

Usage

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 name sans extension ('.plist'). plist files are named with reverse domain name notation. For example:

$ defaults read com.apple.iTunes # 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 com.apple.Safari AddressBarIncludesGoogle 0

$ # or

$ defaults write com.apple.Safari AddressBarIncludesGoogle -bool NO # case-sensitive!

Using "1", "YES", or "TRUE" instead restores this to the default of including search.

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

$ defaults delete com.apple.AddressBook

= Compound values =

defaults prints values in the OpenStep format. It allows the VALUE to be arrays and dicts, as long as they conform to old-style plist syntax.{{Cite web |title=macos - modifying a Plist from command line on Mac using Defaults |url=https://stackoverflow.com/questions/13740337/modifying-a-plist-from-command-line-on-mac-using-defaults |website=Stack Overflow}}

Settings

Some example settings configurable with defaults under macOS:

class="wikitable sortable"

|+ Globally-available defaults (works in {{tt|NSGlobalDomain}} or application settings)

KeyOSX VersionLegal ValuesDefault Value
AppleAquaColorVariant10.81, 61
AppleHighlightColor10.8RGB, 3 floats range 0-1.0"0.780400 0.815700 0.858800"
AppleShowScrollBars{{Cite web |last=grg |date=26 August 2013 |title=macos - Enabling Scroll Bars In Mountain Lion? |url=https://apple.stackexchange.com/a/100062/153976 |website=Ask Different}}10.8Automatic, WhenScrolling, AlwaysAutomatic
NSQuitAlwaysKeepsWindows{{Cite web |date=26 September 2012 |title=Disable 'Resume' system-wide |url=https://www.defaults-write.com/disable-resume-system-wide/ |website=defaults-write.com}}10.8boolfalse
NSAutomaticWindowAnimationsEnabled{{Cite web |date=11 November 2017 |title=10 terminal commands to speed up macOS High Sierra on your Mac |url=https://www.defaults-write.com/speed-up-macos-high-sierra/ |website=defaults-write.com}}10.8booltrue
NSNavPanelExpandedStateForSaveMode{{Cite web |last=Bynens |first=Mathias |title=mathiasbynens/dotfiles: .macos |url=https://github.com/mathiasbynens/dotfiles/blob/master/.macos |access-date=1 March 2020 |website=GitHub |language=en}}10.8boolfalse
NSWindowResizeTime10.8float:time in seconds.2
CGFontDefaultAllowsFontSmoothing{{Cite web |title=Issue 858861: No subpixel antialiasing under macOS Mojave |url=https://bugs.chromium.org/p/chromium/issues/detail?id=858861 |website=bugs.chromium.org}}10.14?boolean

SS64 documents a set of other keys that can be changed for each software (not the global domain) in macOS.{{Cite web |title=System preference settings for macOS - macOS - SS64.com |url=https://ss64.com/osx/syntax-defaults.html |website=ss64.com}} Other sites also document settings to be changed using defaults.{{Cite web |title=Top 11 Terminal Command Tricks for Mac That You Should Know |url=https://www.guidingtech.com/top-terminal-command-tricks-mac-macos/ |website=Guiding Tech|date=19 August 2019 }} Apple does not publish a complete list of these "secret knobs", but their support site does occasionally provide defaults commands for user to change a certain setting, such as the creation of .DS_Store.{{Cite web |title=Adjust SMB browsing behavior in macOS High Sierra 10.13 and later |url=https://support.apple.com/en-us/HT208209 |access-date=5 January 2020 |website=Apple Support |language=en}} (type into a search engine to find more: site:support.apple.com "defaults write")

GNUstep documents its defaults more clearly, so that there is no such thing as a "hidden settings" community like there is for macOS.

References

{{Reflist}}