【2020-11-28】Mac快速安装Homebrew

159 阅读1分钟

安装homebrew,在国内太折磨了

1. 获取homebrew安装脚本

  1. 使用浏览器打开 install.sh,使用文本复制内容,并保存install.sh
  2. githubHomebrew/install仓库, downlaod或者clone也行

2. 修改install.sh的内容

找到35行的关键字BREW_REPO

BREW_REPO="https://github.com/Homebrew/brew"
# 修改为
BREW_REPO="https://mirrors.ustc.edu.cn/brew.git"

3. 使用Terminal安装

命令cdinstall.sh的文件夹,执行

./.install.sh

然后瞬间就完成安装

4. 安装homebrew-core

安装完了才能使用homebrew

# 前往homebrew的library
cd /usr/local/Homebrew/Library/Taps/homebrew (如果没有homebrew,新建homebrew文件夹)
# 然后clone清华源的homebrew-core
git clone https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/homebrew-core.git

5.【关键】替换repo为清华源

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

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

# 最后Update一下,瞬间完成
brew update

感谢参考资料

借鉴