配置 Homebrew
下载并安装
设置环境变量
从 macOS Catalina(10.15.x) 版开始,Mac使用zsh作为默认Shell,使用.zprofile,所以对应命令:
echo 'eval "$(/opt/homebrew/bin/brew shellenv)"' >> ~/.zprofile
eval "$(/opt/homebrew/bin/brew shellenv)"
如果是 macOS Mojave 及更低版本,并且没有自己配置过zsh,使用.bash_profile:
echo 'eval "$(/opt/homebrew/bin/brew shellenv)"' >> ~/.bash_profile
eval "$(/opt/homebrew/bin/brew shellenv)"
参考文档
修改环境变量
Zsh 增加环境变量
- Edit ~/.zprofile
sudo vi ~/.zprofile
- Add new path to ~/.zprofile
export PATH="$PATH:[NEW_DIRECTORY]/bin"
- Update ~/.zprofile
source ~/.zprofile
- Check PATH
echo $PATH