让 HomeBrew 加速起飞

6,938 阅读1分钟

前言,在我国做程序员有天生的劣势,主要分为语言网络环境

点到即止,brew update 真心慢的一批

今天鄙人有幸分享一下如何让电脑上的 homebrew 加速起飞

1. 修改源镜像

鄙人用的是清华大学镜像站

1.1 替换

git -C "$(brew --repo)" remote set-url origin https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/brew.git

git -C "$(brew --repo homebrew/core)" remote set-url origin https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/homebrew-core.git

git -C "$(brew --repo homebrew/cask)" remote set-url origin https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/homebrew-cask.git

brew update

1.2 还原(如果还是喜欢 github 更新的话)

git -C "$(brew --repo)" remote set-url origin https://github.com/Homebrew/brew.git

git -C "$(brew --repo homebrew/core)" remote set-url origin https://github.com/Homebrew/homebrew-core.git

git -C "$(brew --repo homebrew/cask)" remote set-url origin https://github.com/Homebrew/homebrew-cask.git

brew update

2. 修改bottles

打开你正在使用的shell配置文件,例如:.zshrc

在文件中合适位置(你看哪里顺眼加哪里,无所谓)加入以下变量

export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.tuna.tsinghua.edu.cn/homebrew-bottles

3. 完工

再试试 brew update, 是不是单车变摩托