modifying a Plist from command line on Mac using Defaults

Just a coder picture Just a coder · Dec 6, 2012 · Viewed 47.4k times · Source

Does any one know how to modify a Plist file from command line using defaults? Currently there are two Dictionaries under the URL types array; I need to add another.

enter image description here

Every command i've tried have either replaced the entire dictionary, or created a new array called URL types instead of editing it. Any ideas of how this can be done in defaults (the console Mac app) and not PlistBuddy?

Answer

ctpenrose picture ctpenrose · Oct 31, 2013

XML property lists can be viewed in a text editor directly as Lauri's answer above suggests.

Binary property lists (found in many of Apple's own shipping applications) need to be converted to an XML property list format first.

plutil may be used to do this, in either direction. Take care though as the property list is modified in place, so you make wish to make a copy of the property list first.

plutil -convert xml1 binary-property-list-to-convert.plist

And to convert it back to binary:

plutil -convert binary1 XML-property-list-to-convert.plist