June 29, 2011

Using plutil to view your Mac OS X Perforce preferences

Traceability

Starting with version 2010.2, 'p4 set' on Mac OS X can now be used to set Perforce variables as user or system preferences in your Mac preferences folder. For example, you can do:

p4 set P4USER=bryan

to persistently store the definition of the P4USER variable on your Mac, and then you don't have to remember to set it each time.

When you do this, the variable is added to a "plist" file in your preferences folder, i.e., to

~/Library/Preferences/com.perforce.environment.plist

This file is written in a binary format, which is a bit awkward to read using your normal text editor, so here's a nice shortcut:

plutil -convert xml1 ~/Library/Preferences/com.perforce.environment.plist -o -

This will print your preferences to the screen, in a mostly-human-readable format called XML.

Enjoy!