rentzsch.com: tales from the red shed

Saving and Restoring Color Picker Favorites

Mac OS X
I've been using the same home folder since around 10.1. While it's great to maintain your setup while jumping from one OS version to the next, the downside is that you collect pref cruft. Oodles of outdated files in ~/Library/*.

About a month back I bit the bullet, created a new home folder and switched to using it. I demand-paged-in necessary preference files as I noticed they were missing ("Oh, OmniGraffle Pro 3 thinks I don't own it, better copy over that software license file").

One pref that was missing, which was nonobvious to restore, was my custom color favorites I defined in the Color Picker palette. Turns out the data is stored in ~/Library/Preferences/.GlobalPreferences.plist under the key NSColorSwatchData (thank you fs_usage!).

Here's a command that will save your custom colors to an external file:

defaults read -g NSColorSwatchData|sed -e 's/[<> ]//g'>myColors

The call to sed strips out formatting that defaults can't understand when read back in (Radar #3616001). Here's a command that will read that file back in:

defaults write -g NSColorSwatchData -data `cat myColors`

Wednesday, April 07, 2004
11:22 PM