Homebrew 是一个免费的开源软件包管理系统,可简化在 MacOS 上安装软件的流程。

官网:https://brew.sh/ (英文) 官网:https://brew.sh/index_zh-cn (中文)

根据我实际体验,这种方法只能说勉强,效果并不好,所以还是 科 学 上 网 吧!😂

设置镜像

  1. # 替换 brew.git
  2. cd "$(brew --repo)"
  3. git remote set-url origin https://mirrors.ustc.edu.cn/brew.git
  4. # 替换 homebrew-core.git
  5. cd "$(brew --repo)/Library/Taps/homebrew/homebrew-core"
  6. git remote set-url origin https://mirrors.ustc.edu.cn/homebrew-core.git
  7. # 替换 homebrew-cask.git
  8. cd "$(brew --repo homebrew/cask)"
  9. git remote set-url origin https://mirrors.ustc.edu.cn/homebrew-cask.git
  1. # 对于 bash 用户:
  2. echo 'export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.ustc.edu.cn/homebrew-bottles' >> ~/.bash_profile
  3. source ~/.bash_profile
  4. # 对于 zsh 用户
  5. echo 'export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.ustc.edu.cn/homebrew-bottles' >> ~/.zshrc
  6. source ~/.zshrc

取消设置

  1. # 重置 brew.git
  2. cd "$(brew --repo)"
  3. git remote set-url origin https://github.com/Homebrew/brew.git
  4. # 重置 homebrew-core.git
  5. cd "$(brew --repo)/Library/Taps/homebrew/homebrew-core"
  6. git remote set-url origin https://github.com/Homebrew/homebrew-core.git
  7. # 重置 homebrew-cask.git
  8. cd "$(brew --repo homebrew/cask)"
  9. git remote set-url origin https://github.com/Homebrew/homebrew-cask

~/.zshrc 或者 ~/.bash_profile 删除或者注释掉

  1. export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.ustc.edu.cn/homebrew-bottles