Custom Environment Variables in Mac OS X 10.6 (Snow Leopard)
Coming from a Linux system, I am used to creating custom environment variables with:
export MY_VAR="the content of my variable"
With this, if I type $MY_VAR, my shell interprets that as:
the content of my variable
Very handy for saving typing. Now, in Linux, you can add that line to your ~/.profile file so that it persists for all future shell sessions.
I learned today that this does not work in Snow Leopard. It took me awhile, but I figured out how to do it. If you know an easier way, please let me know.
Open terminal, and goto your home directory.
$cd
Then, create the directory called .MacOSX
$mkdir .MacOSX
Now you have 2 choices. The first is to add the following into the file ~/.MacOSX/environment.plist:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN"
"http://www.apple.com/D TDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>MY_VAR</key>
<string>the content of my variable</string>
</dict>
</plist>Of course, you'll need to change 'MY_VAR' and 'the content of my variable' to the values that you want.
Your other option is to open XCode, create a new file called environment.plist of type plist, then enter the key and value that you'd like. Place that file in ~/.MacOSX/
After either of these solutions, simply log out then back in and you should be good to go.
