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

网上说法都是

发现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,但自此问题解决

猜你喜欢

转载自www.cnblogs.com/n031/p/11910788.html
今日推荐