This site runs best with JavaScript enabled.

Scripting MacOS Configuration

Photo by Sigmund on Unsplash


Tips for scripting your mac setup.

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.

    1defaults 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.

    1defaults 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:

1# Mouse: enable right-click
2defaults write com.apple.AppleMultitouchMouse MouseButtonMode TwoButton

Discuss on TwitterEdit post on GitHub

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.

Join the Newsletter



Dustin Davis