User Tools

Site Tools


Sidebar

Go Back

Refresh

You are not allowed to add pages

Direct Link

library:ios:defaults

Defaults

1. Command line

1.1 Basic command

defaults write com.apple.finder AppleShowAllFiles -string YES

Let’s take it apart to get familiar with the terminology used throughout this article:

  • defaults - interface
  • write - method
  • comapple.finder - domain
  • AppleShowAllFiles - key
  • -string - type descriptor
  • YES - new value

1.2 Method

  • read - prints current user settings
  • read-type - prints the type of given key
  • write - writes new settings
  • delete - deletes a key or a full domain
  • domains - prints the full list of domains
  • find - searches all domain and keys for a given name
  • help - I’m sure you know what this does

1.3 Domains — system components and installed apps

Domains are objects that contain settings for a particular system component, installed application or a configuration .plist file located in /Library/Preferences/.

# List all domains
defaults domains
defaults domains | tr ',' '\n'

2. Read/Write/Modify a key

2.1 A basic workflow to amend user defaults

  1. Print the settings for the notes app to find the right key.
  2. Check the value type for a given key.
  3. Write new settings.

2.2 The way to find the domain & key responsible for a setting

  1. Save a state before a change.
  2. Make a change through GUI.
  3. Save a state after a change.
  4. Find the difference.

2.3 Example: Systempreferences - Shortcuts

# Read global shortcuts
defaults read -g NSUserKeyEquivalents
defaults read-type -g NSUserKeyEquivalents
## Type is dictionary

# Write global shortcuts
defaults write -g "NSUserKeyEquivalents" -dict \
"Copy" "^C" \
"Paste" "^V" \
"Select All" "^A" \
"Cut" "^X" \
"Undo" "^Z" \
"Redo" "^Y" \
"Find..." "^F" \
"Replace" "^R" \
"Find Next" "\\Uf706" \
"Find Previous" "$\\Uf706" \
"Save..." "^S" \
library/ios/defaults.txt · Last modified: 2022/05/02 00:32 (external edit)