This site runs best with JavaScript enabled.

Scripting MacOS Configuration

Scripting MacOS Configuration Scripting MacOS Configuration

Photo by Sigmund on Unsplash

Recently, I deleted my hard drive and re-installed MacOS. Before I did that, I spent a lot of time building out some scripts to make sure I had everything backed up and that I could get everything set up quickly.

For my .macos setup script, I used https://mths.be/macos as a starting point. It was a huge help. I just went through and made changes to fit my personal preferences.

But what about things that are not on that script? How do you figure out what defaults keys to edit?

Here is how I went about it...

  1. Read all defaults values and save them to a file.

    defaults read > before.json
  2. Make a change. For example, I went into System Preferences -> Mouse -> enabled Secondary click

  3. Read all defaults again and save them to a different file.

    defaults read > after.json
  4. Use your favorite diff tool to compare before.json to after.json to see what has changed.

This should help you figure what your command is to edit. For my example above, I added the following to my setup script:

# Mouse: enable right-click
defaults write com.apple.AppleMultitouchMouse MouseButtonMode TwoButton
Share article
Dustin Davis

Dustin Davis is a software engineer, people manager, hacker, and entreprenuer. He loves to develop systems and automation. He lives with his wife and five kids in Utah.