My recent tip about using Keyboard Maestro to toggle the visiblity of hidden items in Finder (which turned out to be irrelevant for Sierra users; just hold ⌘⌥.) works by checking a hidden macOS preferences setting. In this case, I checked for the existence of the AppleShowAllFiles key, which let me toggle the visiblity of invisible files based on the result of the check.
Controlling a macro—or a shell script or AppleScript—by checking (visible or hidden) preference values can be very useful. But how do you find out the name of the preference you need to check, and in which domain (preferences file) you’ll find it? Hidden prefs are actually easiiest, because the command you use to write them tells you both the preference name and its location. For the hidden files in Finder tip, for instance, the command is this:
So to check that in a script, I just need to save the results of defaults read com.apple.Finder AppleShowAllFiles into a variable, and I can then take action based on the variable’s value. But what about a normal pref, in an application (or in System Preferences)? Say you wanted to check whether Apple’s Pages app was set to show its rulers in inches or centimeters…
Why would you want to know this setting? I don’t know, I was just trying to come up with an example. Just go with it…
How do you find out the key name associated with that particular preference, and what file it’s stored in? I use a couple of different methods.
I use Bare Bones’ BBEdit for most of my text editing, but there’s one thing it does that drives me crazy: It will replace your “find” search terms with something you’ve used elsewhere. It goes like this…
Set up a complex find/replace that you need to do a number of times in BBEdit.
Do some finding and replacing, then switch over to another app to do some other stuff, including copying and searching.
Switch back to BBEdit, open the Find dialog…and discover that the Find box now contains the text you used for searching in the other app.
Argh! Thankfully BBEdit saves previous queries, so it’s a click to get it back. But I finally got mad enough to search for a better solution, and found it on a previously unknown to me expert preferences page on Bare Bones’ site.
There’s lots of good stuff on that page, but this section is the one of interest for the “Find” problem:
Like many Mac OS X applications, BBEdit supports the “Find Scrap”, a feature of the OS that enables sharing of the “search for” string between applications. Some applications put inappropriate content (such as Web search strings) on the Find Scrap, which can cause the “search for” string in BBEdit’s Find dialog to be replaced when you didn’t expect it.
Bingo! Quit BBEdit, open Terminal, paste this line, hit Return, and relaunch BBEdit:
defaults write com.barebones.bbedit FindDialog_UsesFindScrap -bool NO
No longer will your expertly-constructed Find string be replaced by interlopers from the outside world.
For those who aren’t aware, defaults write is a Terminal command that can be used to modify applications’ settings. While you can use these commands to modify settings that are present in an app’s Preferences panel, the more-common use of this command is to set non-visible (hidden) prefs that you won’t find in the GUI.
Here are three of my favorites—three that not only perceptually but actually increase the speed of your interactions with your Mac. I still, to this day, execute these commands on any new Mac I set up.
Sheets are the attached windows that roll down from (and up into) the title bar of windows, such as the Save dialog in most macOS applications. The animation of these sheets, while visually appealing, does take some time.
Using this tip, you can basically eliminate the animation, greatly speeding the appearance and disappearance of sheets. Given how pervasive sheets are, this tip can save a lot of time each day. While the other tips offer actual speed improvements, they’re nothing like the change you get by changing the sheet animation speed.
As a test, I opened and closed a Save sheet in TextEdit five times, both before and after applying this tip:
If you’re scoring at home, that’s a 47% reduction in the time required for just five cycles of a Save sheet.