Copy variables from command line to GUI environments

Jul 22, '04 10:17:00AM

Contributed by: frodeaux

If you use the UNIX command line environment under OS X, you probably know that the environment symbols you set up in your .bashrc file are not reflected in the GUI environment. In the GUI environment, symbol values are read from the file "~/.MacOSX/environment.plist". Apple has a Developer Note which explains this in some detail.

It's tiresome and error prone to attempt to keep these two sets of symbol definitions in sync. The following python script, run from a Terminal window, will generate a new environment.plist file containing ALL of the symbols defined currently in the command line environment. Start a new terminal window and run this script each time you change your .bashrc file. The changes to the environment symbol definitions will become active the next time you log in (the next time enviornment.plist is read).

View the source for environmentPlist.py. Copy and paste into your favorite Unix text editor. Save the script somewhere on your path, and remember to make it executable.

[robg adds: I haven't tested this one, but I did check the script to make sure there's nothing malicious in it.]

Comments (11)


Mac OS X Hints
http://hints.macworld.com/article.php?story=20040715133738459