HowTo: Set an Environment Variable in Mac OS X - $HOME/.MacOSX/environment.plist
Environment variables that are set in ~/.MacOSX/environment.plist
are available to all applications, not just the Terminal, however it can only set user specific environment variables.
By default, the ~/.MacOSX/environment.plist
file does not exist, so we will have to create it. Once created we will need a program that can edit .plist
files, such as Xcode.
Open the Terminal program, you’ll find it in the Utilities folder in the Applications folder, and issue the following command to create the .MacOSX
directory:
Terminal - hostname:~ user$
1
mkdir -p ~/.MacOSX
Now we’ll create the environment.plist
file:
Terminal - hostname:~ user$
1
echo "" > ~/.MacOSX/environment.plist
touch ~/.MacOSX/environment.plist
instead, Xcode complains The data couldn't be read because it has been corrupted.
.Now we can open the file
Terminal - hostname:~ user$
1
open ~/.MacOSX/environment.plist
Right click on the window and pick Add Row
Set the key
Set the value
We’re done adding this environment variable.
Save the file and quit. Go to the apple menu and log out. Log in again and your environment variable is set.
Resources
- Xcode 4 on the Mac App Store (for Mac OS X 10.7)
- Xcode 3.2.6 and iOS SDK 4.3 (for Mac OS X 10.6)
Parts of this series
- HowTo: Set an Environment Variable in Mac OS X
- HowTo: Set an Environment Variable in Mac OS X - Prerequisites
- HowTo: Set an Environment Variable in Mac OS X - Terminal Only
- HowTo: Set an Environment Variable in Mac OS X - $HOME/.MacOSX/environment.plist
- HowTo: Set an Environment Variable in Mac OS X - /etc/launchd.conf
- HowTo: Set an Environment Variable in Mac OS X - launchd.plist