Mac 终端每次启动都要执行 source .bash_profile

社会主义新天地 提交于 2019-12-05 06:31:25

网上说法都是

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

但是我搜索zsh找到的只有一个叫做「oh my zsh」的东西,我并没有装这个软件

还有一种说法是修改.profile文件,试过了,不好使


最后我在Stack Overflow上找到了答案

https://stackoverflow.com/questions/15733508/why-do-i-need-to-source-bash-profile-every-time

Now that we've narrowed down the problem:

  1. Run ps -p $$ at the command line to determine that you are, in fact, using a bash shell.
  2. Realize that you are in zsh, which means you should be editing your profile in .zshrc.
  3. Copy the offending lines from .bash_profile to .zsh, OR
  4. Modify your .zshrc to directly source your .bash_profile.

执行ps -p $$,发现结果是

  PID TTY           TIME CMD
  692 ttys000    0:00.03 -zsh

好吧。。。虽然不知道是为什么会是zsh,但自此问题解决

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!