打开终端
cd /Users/用户名
是否存在.bash_profile
open .bash_profile
不存在即创建
touch .bash_profile
打开编辑后,让.bash_profile配置的全局变量理解生效
source ~/.bash_profile
可能不起作用,原因是 mac下采用zsh代替bash,而zsh加载的是 ~/.zshrc文件,而 ‘.zshrc’ 文件中并没有定义任务环境变量。
解决办法
在~/.zshrc文件最后,增加一行:
source ~/.bash_profile