See All Previously Used Defaults Commands in Mac OS X
It’s easy to lose track of all the defaults commands used to perform tweaks to Mac OS X, but with the help of the history command it’s easy to list every defaults write and accompanying defaults delete commands ever used on a Mac. Launch the Terminal to get started.
See All Defaults Commands Executed
To see all defaults commands, including defaults write, defaults read, defaults delete, and even those requiring sudo:
history |grep "defaults"
Will return something like this:
47 sudo defaults write /Library/Preferences/com.apple.loginwindow AdminHostInfo HostName
48 sudo defaults write /Library/Preferences/com.apple.loginwindow AdminHostInfo IPaddress
98 defaults write com.apple.DiskUtility DUDebugMenuEnabled 1
206 defaults write com.apple.Safari IncludeInternalDebugMenu 1
237 defaults write com.apple.dock itunes-notifications -bool TRUE;killall Dock
238 defaults delete com.apple.dock itunes-notifications
239 defaults write com.apple.dock desktop-picture-show-debug-text -bool TRUE;
241 defaults delete com.apple.dock desktop-picture-show-debug-text;killall Dock
See Only Defaults Write Commands
To see only defaults write commands, including those requiring sudo:
history |grep "defaults write"
The results will look the same as above, but without showing any defaults read or defaults delete commands.
See Only Defaults Delete Commands
To see which defaults write commands have been reverted, grep for ‘delete’ rather than ‘write’:
history |grep "defaults delete"
See Defaults Commands Related to Specific App
By changing the text within grep to an application or process name, we can see which defaults commands were used only for that specific application. For example, to see only defaults commands that impacted the Finder:
history |grep "defaults write com.apple.finder"
Most apps are easy to find this way, and the default applications in OS X almost always follow the ‘com.apple.appname’ convention.
We touched on this concept before in a past post about the history command, but focusing on defaults commands is useful enough to deserve individual recognition.
[…] most frequently used commands, dumping history and searching it to find specific past commands, listing all defaults commands used, or whatever else. That said, there are some obvious situations where you may want to remove that […]
How to clear this history???
Great question, use “history -c” to clear it out.
This inspired a post https://osxdaily.com/2012/12/17/how-to-clear-command-line-history/
Thanks, William,
– Ado
Hey Ado,
No problem!
BTW, your default choice of user name doesn’t pass our comment filter so I’m having to adjust it manually. If you want your comments to go through immediately pick a different username I guess :)
[…] Applications for Mac Users Two of the most common applications for a Mac user is to keep track of defaults entries that have been entered into the Terminal and to quickly find past commands. Query command history […]
Ctrl+r and type defaults, if you retypre ctrl+r you find next occurrence and ctrl+alt+r prev occurrence
Good idea.
Also, add this to .bash_profile and you can actively log commands containing defaults commands.
PROMPT_COMMAND=’echo “$(history 1 | grep “defaults”)” | sed ‘/^$/d’ >> ~/Documents/defaults.txt’
Same idea but just adding each executed command to a text file for easy recall. Adjust the path and filename as necessary.