How can I keep settings consistent between Macs?

I use multiple Macs (OS X Lion). There are a lot of settings, apps, and files I'd like to keep synced up between them. Files are the easiest of the lot -- Dropbox + symlinks, Mercurial repositories, and standalone Puppet manifests are all well-understood and simplish tools. Apps are slightly more difficult, but I'm experimenting with Puppet + PackageMaker + Dropbox to meet this goal.

That brings us to settings. These are also the most obnoxious since I set some small thing on my iMac, promptly forget, then rediscover the annoyance on my MacBook a couple weeks later and have to comb through Google to figure out what I did to fix it the first time.

I discovered the 'defaults' command today and have been exploring it, but I was wondering how everyone else solves this?


By "settings" I mean OS-level configurations like changing the number of Spaces you have, setting hot corners, modifying mouse behavior, etc. App-level configuration would be great, too, but I'm assuming a lot of different apps do this different ways. Oh, how I miss real Unix and its flat configuration files...


There really isn't a one size fits all answer, but I can think of four ways to accomplish your task if you care to spend some time setting this up.


Macs are Unix, so simply check in your ~/Library/Preferences and /Library/Preferences into some sort of code control system. You can then do diffs and most plists are text or easily converted into text (using PlistBuddy) so you can isolate exactly what you have changed.

There are numerous tutorials available - Penn's wiki on Manipulating Plist files is particularly nice and directed to people with unix skills.


There are plenty of Managed System software like Apple Remote Desktop or others like Casper if you wish to get software designed explicitly to manage user preferences.


Server accounts would be easy to set up for minimal cost if you have a spare machine (or virtual machine). Again - some work, but mobile accounts do work well for many people.


Lastly, don't overlook simply migrating the user account from the mac that is correct to the other mac periodically and just making a system where you are disciplined about how you record the times you change a setting.


1) For most OS X applications, settings are kept in ~/Library/Application Support/ and ~/Library/Preferences/

In Terminal.app:

cd ~/Library/Preferences/

plutil -convert xml1  *.plist

And then open any of the plist files in a text editor.

Or, if your text editor of choice is BBEdit, just open the plist files using the bbedit command, which automatically converts them to XML.

Or, just use defaults read on any of those plist files - just leave off the .plist. For example, if you want to read com.apple.dock.plist use defaults read com.apple.dock

2) The defaults command is your friend.

I setup a function that will log all of the defaults write that I make:

defaults ()
{
    if [ "$1" = "write" ]
    then

        LOG="$HOME/Dropbox/dwrites.txt"

        echo "default $@" >>| "$LOG" && echo "[logged defaults change to $LOG]"

    fi

    /usr/bin/defaults $@
}

That way I have a record of all of my changes that I make on the command line.

But, of course, there are lots of these sorts of changes that I don't make on the command line, but make through System Preferences or individual app preferences.

A few of those are even system-level changes that get stored in /Library/Application Support/ or /Library/Preferences/

3) Also checkout the networksetup and systemsetup commands.


Agree with bmike that there really isn't any one size fits all solution besides migrating the user account or cloning one drive into the other periodically.

I'd recommend checking out something like SpiderOak for syncing directories. It lets you choose which directories on the machine you want to back up and sync, rather than giving a predefined place to put your files like Dropbox. No more messing with symlinks.

You should be able to sync most Mac apps by syncing the /Applications folder between machines. Much of your application settings will reside in ~/Library and /Library. You'll probably want to sync your home folder and any other folder you store data files in as well.

I have this set up for my home folder, and large chunks of my ~/Library and /Library on two of my machines. I've never tried syncing /Applications, but in theory it should work.

With regards to settings you've applied via the command line, I suggest writing a shell script that resides in one of these synced folders, and setting both your machines to run it periodically, through cron or some other utility.

Every time you find a new command line setting that you like, add it to the shell script. The script's contents will sync across the 2 machines and since they're both being run periodically, it will update the settings on both machines.

This isn't 100%, but it gets me far enough that manually handling the rest of stuff isn't that painful.