Editing Property Lists
Many preference and configuration files in Mac OS X use property lists (plists) to specify the attributes, or properties, of an application or process. An example is the Finder’s preferences plist in the Library/Preferences/ folder of a user’s home folder. The file is named com.apple.Finder.plist. The default naming convention for a plist includes the distributor’s reverse DNS name prepended to the application or process name, followed by a“.plist” extension.
Property lists are binary files that you can edit using the following tools:
 Property List Editor is a graphical application that’s a part of the Xcode developer tools. You can get the Xcode tools from developer.apple.com. Property List Editor is most useful if you already understand property lists and their conventions.
 PlistBuddyPlistBuddy is a command-line tool for directly reading and modifying values inside a property list without the need to convert the property list to an intermediary format.
 defaults is a command-line tool that you can use to edit property lists.
The defaults command is a powerful tool, with functionality beyond simple editing of property lists. When you know the specific key and value in a property list that you need to change, it’s very efficient.
A plutil is a command-line tool that you can use to change a property list into a format you can edit with a text editor, and then change back to its binary format.
Using PlistBuddy to edit property lists
The PlistBuddy command is designed to easily read and modify values in a property list. If you know the values to set or read, you can quickly make changes with PlistBuddy. PlistBuddy works on specific property list files.
This example shows how to use the PlistBuddy command interactively to change the orientation of the Dock for a local user:
1 Determine the names of the appropriate property list, key, and values. In this case, the name for the Dock’s property list is com.apple.Dock.plist. If you were editing the Dock property list for the user alecjones, the path would be:
/Users/raza/Library/Preferences/com.apple.Dock.plist 2 Enter in the following command to enter the PlistBuddy interactive mode:
PlistBuddy /Users/raza/Library/Preferences/com.apple.Dock.plist If the path to PlistBuddy isn’t in your default paths, you need to add it or explicitly
call it as follows:
/usr/libexec/PlistBuddy ~/Library/Preferences/com.apple.Dock.plist
See “Executing Commands and Running Tools” on page 13.
If the file you’re trying to edit doesn’t exist, PlistBuddy creates the file in the designated location.
3 In interactive mode, you can choose from many commands. To set or change the orientation of the Dock to the left side of the screen, enter:
Set :orientation left
4 Save and exit: Save
Exit PlistBuddy can also be run non-interactively. To make the same change without
invoking interactive mode:
/usr/libexec/PlistBuddy -c « Set :orientation left » ~/Library/Preferences/ com.apple.Dock.plist
Both examples above assume the orientation key already exists. This isn’t necessarily true for a new user in Mac OS X version 10.6. Don’t assume that a value exists. First, confirm it with the Print command. Otherwise, you need to use the Add command, which also requires designating a type.
There are many other options for PlistBuddy that are invoked in a similar manner. For information about PlistBuddy, see its man page.
Using the defaults command to edit property lists
The defaults tools works directly with the Mac OS X preferences subsystem and is used by many applications in Mac OS X to manage preferences and other settings. It can be built into shell scripts and allows you to access preferences in the multiple domains that exist on a given computer.
Determine the names of the appropriate property list, key, and values. For example, the name for the Dock’s property list is com.apple.Dock.plist. (When invoking the defaults command, omit the .plist extension.)
Using the values you have determined or been given, enter their values following the defaults command:
defaults write com.apple.dock orientation left
In most cases, you need to restart the application or process. A simple way to do this is to use Activity Monitor to select the appropriate process, and then click Quit Process. For this example, you would choose the process named Dock.
For information about defaults, see its man page.
Using plutil and a text editor to edit property lists
In Mac OS X v10.6, plist files are stored in a binary format. If you want to edit them with a text editor, you must first convert them to plain text. To convert a plist file to plain text, use the plutil command:
plutil -convert xml1 com.apple.dock.plist
This results in an XML text file that you can edit. When you’re done, convert the file back to binary format:
plutil -convert binary1 com.apple.dock.plist Before making any changes to plist files using plutil, make a backup copy of the files.
Do this in the Finder, or use the cp command: cp com.apple.finder.plist com.apple.dock.plist.bak