Take the 2-minute tour ×
Ask Different is a question and answer site for power users of Apple hardware and software. It's 100% free, no registration required.

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.

share|improve this question

2 Answers 2

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 -.

share|improve this answer

This piece of bash solved my problem:

if [ ! -f '~/.MacOSX/environment.plist' ]; then
  mkdir -p '~/.MacOSX'
  defaults write ~/.MacOSX/environment.plist TEST_VAR 1
fi

Still, I have to warn others that OS X 10.8 seems not to be loading the file.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.