How to create a binary plist file from the command line on OS X

defaultsplist

I am looking for a solution to create a binary plist file from the command line on OS X?

I want to create the ~/.MacOSX/environment.plist and setup the PATH there.

I know that this plist file has to be in the binary format and I know how to write to it using the defaults write command. Still, I do need to create the file before doing this, and creating an empty file does not work.

Note: I need a command line solution.

Best Answer

You could also create an XML or old-style property list and convert it with plutil:

plutil -convert binary1 test.plist

It modifies files in place by default. You can specify a different output file with -o or print to stdout with -o -.