转载https://www.bilibili.com/video/BV11i4y1c7BD?from=search&seid=3913240024604725138
1. 安装 ARM 版 Homebrew
cd /opt # 切换到 /opt 目录
mkdir homebrew # 创建 homebrew 目录
curl -L https://github.com/Homebrew/brew/tarball/master | tar xz --strip 1 -C homebrew
Intel安装
arch -x86_64 /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
vim ~/.zshrc 或者 vim ~/.bash_profile
# x86
export PATH ="/usr/local/bin:$PATH"
export abrew="arch -x86_64 /usr/local/bin/brew"
# arm
export PATH="/opt/homebrew/bin:$PATH"
alias brew="/opt/homebrew/bin/brew"
source ~/.zshrc 或者 source ~/.bash_profile
2.换源
# arm版
cd "$(brew --repo)"
git remote set-url origin git://mirrors.ustc.edu.cn/brew.git
cd "$(brew --repo)/Library/Taps/homebrew/homebrew-core"
git remote set-url origin git://mirrors.ustc.edu.cn/homebrew-core.git
#intel 版
cd "$(abrew --repo)"
git remote set-url origin git://mirrors.ustc.edu.cn/brew.git
cd "$(abrew --repo)/Library/Taps/homebrew/homebrew-core"
git remote set-url origin git://mirrors.ustc.edu.cn/homebrew-core.gitE
替换homebrew-bottles (预编译如今只软件包)
bash用户
echo 'export HOMEBREW_BOTTLE_DOMAIN=https://mirror.ustc.edu.cn/homebrew-bottles' >>~/.bash_profile
source ~/.bash_profile
zsh用户
echo 'export HOMEBREW_BOTTLE_DOMAIN=https://mirror.ustc.edu.cn/homebrew-bottles' >>~/.zshrc
source ~/.zshrc