天天看点

【工作日常】Mac 解决每次新建终端 都要重新运行 source ~/bash_profile问题

本文copy from

https://blog.csdn.net/science_Lee/article/details/79214127

环境

MacBook Pro (13-inch, 2020, Two Thunderbolt 3 ports)

terminal

问题

在 ~/.bash_profile 中配置环境变量, 每次重启(新建窗口)终端后配置的不生效.需要重新执行 : $source ~/.bash_profile

原因

这是因为其默认启动执行脚本变为了 ~/.zshrc。

zsh加载的是 ~/.zshrc文件,而 ‘.zshrc’ 文件中并没有定义任务环境变量(即不会加载:.bash_profile 中配置,导致不生效)。

解决办法

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

source ~/.bash_profile
           

继续阅读