Hacking environment.plist

Recently I needed to set some environment variables for a little project I was doing in BBEdit. Aqua applications do not really care about whatever shell I use in the terminal, so they do not read my login files.

Since I do not like to maintain the same information in two places, I made a short script to turn my shell environment into my environment.plist. I added a short function to Mac::PropertyList to turn a simple hash into a plist (I have not fully implemented the pieces to turn an arbitrary data structure into a plist, though).

#!/usr/bin/perl

use Mac::PropertyList;

print Mac::PropertyList::create_from_hash( \%ENV )

From that I get a plist, which I can save as ~/.MacOSX/environment.plist. I edited the output a bit to give you a flavor of the final plist. You can edit plists by hand or with the PropertyListEditor application.

At some point I can extend this to automatically recognize when my shell environment has a permanant change (e.g..bash_profile changes) and then regenerate the environment.plist. I still have to log out and log in again for the changes to take effect, so I have to figure out how to hack that some time. If I can figure that out, I can make the process happen through some sort of scheduler magic or create a tool to "source" the plist.