安装homebrew,在国内太折磨了
1. 获取homebrew安装脚本
- 使用浏览器打开 install.sh,使用文本复制内容,并保存
install.sh - 到
github的Homebrew/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安装
命令cd到install.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