[macOS] HomeBrew更换国内源

HomeBrew是macOS下的包管理软件,默认源是国外站点,速度较慢且不稳定,通过更换国内源的方式,可以提高下载速度和成功率。以中科大镜像站为例说明更换国内源的步骤。

1
2
3
4
5
6
7
cd "$(brew --repo)"
git remote set-url origin https://mirrors.ustc.edu.cn/brew.git
cd "$(brew --repo)/Library/Taps/homebrew/homebrew-core"
git remote set-url origin https://mirrors.ustc.edu.cn/homebrew-core.git
brew update
echo 'export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.ustc.edu.cn/homebrew-bottles' >> ~/.bash_profile
source ~/.bash_profile