Mac安装homebrew

创建安装目录

1
sudo mkdir -p /opt/homebrew

修改所有者,所属组

1
sudo chown -R $(whoami) /opt/homebrew

安装 homebrew

1
curl -L https://github.com/Homebrew/brew/tarball/master | tar xz --strip 1 -C /opt/homebrew

修改所有者,所属组

1
sudo chown -R $(whoami) /opt/homebrew

修改环境变量

1
echo 'path=('/opt/homebrew/bin' $path) && export PATH' >> ~/.zshrc

刷新环境变量

1
source ~/.zshrc

测试是否安装成功

1
brew