OSX 10.9 Mavericks Environment Variables: How to Set Environment Variables

How can I EXPORT environment variable not only for one tab but for the whole system?

If I use it export JAVA_HOME=/Library/Java/Home

, it will install JAVA_HOME

only for the current terminal tab and after a system reboot, I will need to do it again.

How can I set the default global environment variable?

How can I edit the variables in the list $ env

?

+3


source to share


2 answers


Add an entry to ~/.bash_profile

:

export JAVA_HOME=/Library/Java/Home

      

  • save it (or create it if it doesn't exist)
  • quit Terminal.app
  • restart and you are in business.

This is the best place to add the entry, in my opinion, although for OS X's distinctive differences from where to add environment variables for one reason or another, you can see:



And for a more general overview of UNIX:

+4


source


You can set environment variables by adding export commands to various configuration files. For example. ~ / .profile

You can learn more about which files can be used to change the bash environment by reading the bash ( man bash

) manual . If you are using a different shell, then it is probably similar, and its man page should contain the same information. You can also read this answer on unix.stackexchange.com which contains some of this information.



If you want to set environment variables for your entire user environment, including graphical applications, I believe you can do this with ~ / .MacOSX / environment. PLIST .

0


source







All Articles