1. mac 环境变量介绍
Mac系统的环境变量。 加载顺序为/etc/profile/etc/paths~~/. bash _ profile~~/. bash _ log in~/.profile~~/. bashrc .
a./etc/profileb./etc/pathsc.~~/.bash _ profiled.~~/.bash _ logine.~~/.profilef.~/. bashrc
2. 设置maven环境变量
执行命令
vim ~/.bash_profile写入打开的文件
# scalcscala _ home=/users/wyc/soft/Scala-2.11.12导出路径=$ path : $ Scala _ home /丰富的甜瓜数据线# Mara
source ~/.bash_profile环境变量规则:export自定义名称(MAVEN_HOME )=路径名,以及export path=path : path 3360 path自定义名称)
3. 上面的设置默认使用bash,如果你在Mac上使用的是zsh等shell工具,需要再做如下配置,来达到环境变量设置的永久生效。
vim ~/.zshrc添加到开头
if [ -f ~/.bash_profile ]; 使用以下命令立即启用then source ~/.bash_profilefi
source ~/.zshrc的原因说明如下。
bash的配置文件为. bashrc,zsh的配置文件为. zshrc。 如果魔术外套使用zsh作为缺省外壳工具,则不会加载bash的两个配置文件. bashrc和. bash_profile,而是仅在启动时加载
为了加载自己的配置文件. zshrc并使我们的配置文件生效,只能将上述配置文件添加到. zshrc中。
如果不进行上述设置,则可以看到只有魔术外套在每次source ~/.bash_profile时生效,下次重新打开zsh窗口时无效
参考资料
33559 www.it 610.com/article/1294895372392538112.htm