首页 > 代码库 > Mac OSX - 如何在bash_profile中配置全局环境变量

Mac OSX - 如何在bash_profile中配置全局环境变量

我们知道,在Linux操作系统下,配置环境变量是使用如下命令:

vim /etc/profile

在OSX下,我们用如下命令打开环境变量配置文件:

<style></style>

open ~/.bash_profile

 

典型的环境变量配置如下:

 

# javaexport JAVA_HOME = /home/myuser/jdk1.7.0_03export PATH = $JAVA_HOME/bin:$PATHexport CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar# hadoopexport HADOOP_HOME=/Users/YourUserName/Documents/Dev/hadoop-2.7.3export PATH=$PATH:$HADOOP_HOME/bin:$HADOOP_HOME/sbin# spunkexport SPLUNK_HOME=/Applications/Splunkexport PATH=$PATH:$SPLUNK_HOME/bin# Setting PATH for Python 3.5# The original version is saved in .bash_profile.pysavePATH="/Library/Frameworks/Python.framework/Versions/3.5/bin:${PATH}"export PATHexport CLASSPATH=${CLASSPATH}:/Users/YourUserName/Documents/Lib/hadoop_cli# antexport ANT_HOME=/Users/YourUserName/Documents/Dev/apache-ant-1.9.7export PATH=$PATH:${ANT_HOME}/bin# JBOSSexport JBOSS_HOME=/Users/YourUserName/Documents/Dev/wildfly-10.1.0.Finalexport PATH=$PATH:$JBOSS_HOME/bin# M2_HOMEexport M2_HOME=/Users/YourUserName/Documents/Dev/apache-maven-3.3.9export PATH=$PATH:$M2_HOME/bin

最后,别忘了编译下

source .bash_profile

 

Mac OSX - 如何在bash_profile中配置全局环境变量