Homebrew国内
中科大的镜像
中科大镜像比较稳定,而且速度不错。官方网站:http://mirrors.ustc.edu.cn/。搜索brew,然后点击Help即可查看用法替换Homebrew默认源
# 替换brew.git:
cd "$(brew --repo)"
git remote set-url origin https://mirrors.ustc.edu.cn/brew.git
# 替换homebrew-core.git:
cd "$(brew --repo)/Library/Taps/homebrew/homebrew-core"
git remote set-url origin https://mirrors.ustc.edu.cn/homebrew-core.git
brew update
替换Homebrew Bottles源
#对于bash用户
echo 'export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.ustc.edu.cn/homebrew-bottles' >> ~/.bash_profile
source ~/.bash_profile
#对于zsh用户
echo 'export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.ustc.edu.cn/homebrew-bottles' >> ~/.zshrc
source ~/.zshrc
重置Homebrew默认源
# 重置brew.git:
cd "$(brew --repo)"
git remote set-url origin https://github.com/Homebrew/brew.git
# 重置homebrew-core.git:
cd "$(brew --repo)/Library/Taps/homebrew/homebrew-core"
git remote set-url origin https://github.com/Homebrew/homebrew-core.git
brew update
其他加速方法
除了通过替换源加速之外,如果你有自己的代理,也可以通过代理加速。如socks代理配置:
vi ~/.curlrc
# 改成自己的代理端口
socks5=127.0.0.1:1080