====== Defaults ====== [[https://pawelgrzybek.com/change-macos-user-preferences-via-command-line/#:~:text=Macs%20come%20with%20a%20defaults%20command%20line%20interface,is%20quicker%29.%20defaults%20write%20com.apple.finder%20AppleShowAllFiles%20-string%20YES|Change macOS user preferences via command line]] \\ [[https://apple.stackexchange.com/questions/118482/is-there-any-way-to-save-mac-os-x-preferences-into-a-shell-file|Way to Copy Mac OS X preferences into a shell file]] \\ [[https://blog.csdn.net/lovechris00/article/details/113280758?utm_medium=distribute.pc_relevant.none-task-blog-2~default~baidujs_title~default-0.essearch_pc_relevant&spm=1001.2101.3001.4242|defaults 命令详解]] ===== - Command line ===== ==== - 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 ==== - 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 ==== - 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' ===== - Read/Write/Modify a key ===== ==== - A basic workflow to amend user defaults ==== - Print the settings for the notes app to find the right key. - Check the value type for a given key. - Write new settings. ==== - The way to find the domain & key responsible for a setting ==== - Save a state before a change. - Make a change through GUI. - Save a state after a change. - Find the difference. ==== - 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" \