Published at
Updated at
Reading time

If you're using a Mac, you might have come across tutorials explaining how to change particular macOS configuration via the command line.

For example, I google and found this command to add a spacer tile to the macOS dock.

defaults write persistent-apps -array-add '{"tile-type"="spacer-tile";}'

These commands can offer functionality that is not available via the GUI. Additionally, they allow users to automate and script their general macOS configuration. When you're setting up a new development machine, an automated setup can save you hours.

These automation scripts are often places in so-called dotfiles projects. These projects include config files such as .gitconfig and .vimrc and scripts that install additional software and configure the operating system.

Have a look at two examples:

The macOS configuration section in Mathias' dotfiles includes 226 (😲) of default write commands. That's a lot of automation!

When looking at the public dotfiles, I always wondered how people find the commands to change and save macOS settings. As you've seen in the command above, these operating system settings are not guessable.

Today I read the post Change macOS user preferences via command line post written by Paweł Grzybek, and he shared a nifty approach to discovering the commands and arguments yourself.

It includes a plain old diff of your settings' overall state, but read the post yourself; if you want learn more about automating you macOS setup, this post is worth it.

Was this post helpful?
Yes? Cool! You might want to check out Web Weekly for more WebDev shenanigans. The last edition went out 3 days ago.
Stefan standing in the park in front of a green background

About Stefan Judis

Frontend nerd with over ten years of experience, freelance dev, "Today I Learned" blogger, conference speaker, and Open Source maintainer.

Related Topics

Related Articles