2

I would like to transfer a configuration from one Mac to another using the defaults command within BASH.

On one Mac, I can save the configuration by doing:

defaults read edu.ucsd.cs.mmccrack.bibdesk > bibdesk.plist

On the other Mac, I would like to use the defaults command to write what I saved, but nothing I can think of makes this work. I've tried the following:

defaults write edu.ucsd.cs.mmccrack.bibdesk "'$(cat bibdesk.plist)'"
defaults write edu.ucsd.cs.mmccrack.bibdesk "\'$(cat bibdesk.plist)\'"
defaults write edu.ucsd.cs.mmccrack.bibdesk \'$(cat bibdesk.plist)\'

What command will put the configuration back on the other Mac?

3
  • Does find ~ -name 'edu.ucsd.cs.mmccrack.bibdesk*' -print print a path?
    – nohillside
    Commented Feb 29 at 19:59
  • Yes, it prints several paths. I suspect you are looking for the path I already know: ~/Library/Preferences/edu.ucsd.cs.mmccrack.bibdesk.plist.
    – Jim L.
    Commented Feb 29 at 20:49
  • 2
    You can just copy the plist to the new computer, without ever using defaults :-)
    – nohillside
    Commented Mar 1 at 6:48

2 Answers 2

5

I serendipitously found an answer to my own question. Maybe this will help someone else some day.

Someone suggested trying to read from stdin, which doesn't work, but the error message revealed an undocumented sub-command:

import <domain> <path to plist>      writes the plist at path to domain
import <domain> -                    writes a plist from stdin to domain
export <domain> <path to plist>      saves domain as a binary plist to path
export <domain> -                    writes domain as an xml plist to stdout

So, on one Mac I typed:

defaults export edu.ucsd.cs.mmccrack.bibdesk bibdesk.plist

On the other Mac I typed:

defaults import edu.ucsd.cs.mmccrack.bibdesk bibdesk.plist

Done!

Why did Apple have to make this so difficult?!

3
  • 3
    They didn't! You could just copy the plist file from one computer to the other. Still -- nice find that the error text gives more commands than the man pages, and these may have some other uses.
    – benwiggy
    Commented Mar 1 at 9:04
  • I thought I had read that in some cases the plist file permissions don’t allow writing the file without the command, sometimes also requiring sudo.
    – Jim L.
    Commented Mar 1 at 12:05
  • Not the ones inside the user Library. The ones in /Library, maybe.
    – benwiggy
    Commented Mar 1 at 12:25
3

All the defaults command does is pull information from various plist files already stored in specific areas of your local filesystem. When @nohillside asked you to use the find command, the results you got back should have been the plist file you could directly copy from one mac to the other.

One additional tip: You can access the contents of a plist file by running plutil -p followed by the plist file. In this case: plutil -p ~/Library/Preferences/edu.ucsd.cs.mmccrack.bibdesk.plist

It will be in human readable form, but it's a fast way to check to see if that's the file you're after (assuming you know what the contents generally look like).

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .