多文件分类和应用环境变量
-
自定义环境变量文件存放目录
- /usr/local/etc/profile.d:
- java_evn.sh
export JAVA_HOME_7=/Library/Java/JavaVirtualMachines/jdk1.7.0_80.jdk/Contents/Home export JAVA_HOME_8=/Library/Java/JavaVirtualMachines/openlogic-openjdk-8.jdk/Contents/Home export JAVA_HOME=$JAVA_HOME_8 export CLASSPATH=$JAVA_HOME/lib/tools.jar:$JAVA_HOME/lib/dt.jar:. export PATH=$PATH:$JAVA_HOME
- alias_env.sh
alias pg_start='pg_ctl -D /usr/local/var/postgresql@11 -l /usr/local/var/postgresql@11/server.log start' alias pg_stop='pg_ctl -D /usr/local/var/postgresql@11 -l /usr/local/var/postgresql@11/server.log stop'
- java_evn.sh
- /usr/local/etc/profile.d:
-
修改~/.bash_profile, 写入以下内容
for i in /usr/local/etc/profile.d/*.sh; do if [ -r "$i" ]; then if [ "${-#*i}" != "$-" ]; then . "$i" else "$i" >/dev/null fi fi done unset i
-
应用环境变量
source ~/.bash_profile