Mac 每次都要执行source ~/.bash_profile 配置的环境变量才生效

自己在 ~/.bash_profile 中配置环境变量, 可是每次重启终端后配置的不生效.需要重新执行 : $source ~/.bash_profile

发现zsh加载的是 ~/.zshrc文件,而 ‘.zshrc’ 文件中并没有定义任务环境变量。

解决办法

在~/.zshrc文件最后,增加一行:

source ~/.bash_profile

先执行:

cd ~

touch .zshrc

open .zshrc

添加:source ~/.bash_profile

如果没有 .zshrc 文件, 在相应目录下 执行 touch .zshrc 创建文件,添加 source ~/.bash_profile。

完美生效。

你可能感兴趣的:(Mac 每次都要执行source ~/.bash_profile 配置的环境变量才生效)