Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

modifying a Plist from command line on Mac using Defaults

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?

like image 309
Just a coder Avatar asked Dec 06 '12 09:12

Just a coder


People also ask

How do I edit a plist file on a Mac?

plist file. If you need to edit these items, Control-click (or right-click) Info. plist in the sidebar and select Edit Manually. This allows you to add or edit items in raw XML format.

How do I edit locked plist on Mac?

Open it and inside, there should be at least one Plist file called info. plist. Right-click it and select Open With>Xcode. The file will open in Xcode and you can edit the already existing rows of preferences.

How do I edit a file in Mac command-line?

In the Terminal app on your Mac, invoke a command-line editor by typing the name of the editor, followed by a space and then the name of the file you want to open. If you want to create a new file, type the editor name, followed by a space and the pathname of the file.

How do I open a .plist file on a Mac?

plist - The primary property list for Mac OS X applications, located in the /​Contents/​ directory of an . APP bundle. To view this file, right-click an application file, select "Show Package Contents," and open the Contents folder.


1 Answers

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 
like image 142
ctpenrose Avatar answered Oct 15 '22 04:10

ctpenrose