HowTo: Set an Environment Variable in Mac OS X - Prerequisites
Here we will talk about some things you’ll need for setting environment variables in Mac OS X.
Terminal
You will find Terminal in the Utilities folder in the Applications folder.
Print environment variables
Print all environment variables:
Terminal - hostname:~ user$
1
set
Output
1
2
3
4
BASH=/bin/bash
.
.
.
Print a specific environment variable:
Terminal - hostname:~ user$
1
echo $HOME
Output
1
/Users/user
Text Editors
Depending on which method you pick, you’ll need to edit some text files
GUI
TextWrangler
If you pick TextWrangler, we’ll be opening files with File > Open File by Name...
- TextWrangler - Download
Xcode
If you pick Xcode, we’ll be opening files with File > Open Quickly....
If you use the ~/.MacOSX/environment.plist approach, you’ll need Xcode for editing plist files.
- for Mac OS X 10.7 - Xcode 4 on the Mac App Store
- for Mac OS X 10.6 - Xcode 3.2.6 and iOS SDK 4.3
In Terminal
The following editors are already installed.
vi/vimpico/nanoemacs
You will need to use sudo for open some files, notably in /etc.
Example:
Terminal - hostname:~ user$
1
sudo vim /etc/profile
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