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.
Mac OS X does; however, read the ~/.MacOSX/environment.plist file when I log into my account. That environment is available to all applications.
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.
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>POP_USER</key>
<string>comdog</string>
<key>HISTFILESIZE</key>
<string>3000</string>
<key>RSYNC_RSH</key>
<string>/usr/bin/ssh -l comdog</string>
<key>PWD</key>
<string>/Users/brian/Desktop</string>
<key>CVSROOT</key>
<string>/Users/brian/.cvs</string>
<key>HOST</key>
<string>g3.home.staceytappan.com</string>
<key>EDITOR</key>
<string>/usr/bin/vi</string>
<key>PATH</key>
<string>/bin:/usr/bin:/sbin</string>
<key>SHELL</key>
<string>/usr/local/bin/bash</string>
<key>CVS_RSH</key>
<string>ssh</string>
<key>USER</key>
<string>brian</string>
<key>HOME</key>
<string>/Users/brian</string>
</dict>
</plist>
At some point I can extend this to automatically recognize when my shell environment has a permanant change (e.g.