Linux

Linux_bash_profile无法生效.md

2020-10-27  本文已影响0人  儒徒

问题:

~/.bash_profile设置了环境变量,且使用了source ~/.bash_profile使得当前窗口的环境变量生效, 但是关闭终端,重启后,环境变量不再生效.

原因:

说明当前的shell的不是bash.
ps: > 使用以下命令查看当前shell


Snip20201026_178.png

我们使用的shell是zsh,不会自动加载~/.bash_profile,而是自动加载.zprofile文件。这里可以在.zprofile文件加上这么一段

if [ -f ~/.bash_profile ]; then
    source ~/.bash_profile
fi

if要不要都行.
上一篇下一篇

猜你喜欢

热点阅读