1
source ~/.bash_profile

每次设置好环境变量后,保存当前设置,只在 当前命令窗口 下生效!

问题

.bash_profile 中修改环境变量只对当前窗口有效,而且需要 source ~/.bash_profile才能使用
.zshrc 则相当于开机启动的环境变量
你也可以在 .zshrc 文件中加一行 source .bash_profile 解决需要 source 才能使用的问题

编辑~/.zshrc文件

1
vim ~/.zshrc

增加以下内容,保存

1
source ~/.bash_profile