defaults
— the Apple settings database
The defaults
check searches the local macOS defaults database, and asserts that keys are present or missing.
This database contains the configuration of applications that use it, including the standard system preferences and well-behaved third-party apps.
Examples
Check that a value is set:
[[defaults]] domain = 'Apple Global Domain' key = 'AppleAquaColorVariant' value = 6
Because this uses the defaults
command, you can pass a valid value as the wrong type (such as the string '6'
instead of the number 6
) and still have it be set to the correct type.
Check that a value is not set:
[[defaults]] domain = 'Apple Global Domain' key = 'TireCount' state = 'missing'
Some applications will store their preferences in a separate file.
Safari, for example, puts its settings in a file deep within ~/Library/Containers
.
To check it, use file
instead of domain
:
[[defaults]] file = '~/Library/Containers/com.apple.Safari/Data/Library/Preferences/com.apple.Safari' key = 'ShowIconsInTabs' value = '1'
List of parameters
parameter | structure | description |
---|---|---|
domain | string | The defaults domain. |
file | string | Path to the defaults file on disk. |
key | string | The defaults key. |
state | string | Whether the key should be present. This can be 'present' or 'missing' . |
value | string, array, or boolean | The value to expect. |