I have been using Windows since the days of Windows 3.1, and I have become very comfortable mucking around in the guts of the Operating System.
Then I was given a Mac OS X machine to configure for development recently. Setting it up with versions of Java, Ant, and other pieces necessary for development meant that I had to create some new environment variables (like ANT_HOME) and change others (like PATH).
Which raised the question: how do I set environment variables for my account on a Mac?
Here are the steps for OS X 10.13 High Sierra
Then I was given a Mac OS X machine to configure for development recently. Setting it up with versions of Java, Ant, and other pieces necessary for development meant that I had to create some new environment variables (like ANT_HOME) and change others (like PATH).
Which raised the question: how do I set environment variables for my account on a Mac?
Here are the steps for OS X 10.13 High Sierra
- Open a Terminal window (Applications -> Utilities -> Terminal)
- Check for a .profile file in your home directory
$ ls -a - Use an editor like vim or emacs to open the .profile file if it exists, or create it if not.
In vim, press "i" to enter "insert" mode and "Esc" to return to command mode.
$ vim .profile - Add the new environment variables, using the "export" command, e.g.
export ANT_HOME=/Users/Steve/wow/ant/apache-ant-1.10.5 - Add any changes to the PATH environment variable by appending to the end of the existing one, separating by a colon ":" and exporting it, e.g.
export PATH=$PATH:${ANT_HOME}/bin - Save changes. In vim press escape key to return to command mode and enter ":wq" to write the changes and quit the editor.