Mac|安装Homebrew

长话短说

国内从官方镜像安装Homebrew着实不算方便,搭配镜像助手可以获得更好的效果

1
2
3
4
5
6
7
8
 # 1.执行安装脚本(中科大 macOS zsh)
$ export HOMEBREW_BREW_GIT_REMOTE="https://mirrors.ustc.edu.cn/brew.git"
$ export HOMEBREW_CORE_GIT_REMOTE="https://mirrors.ustc.edu.cn/homebrew-core.git"
$ /bin/bash -c "$(curl -fsSL https://cdn.jsdelivr.net/gh/ineo6/homebrew-install/install.sh)"
# 2.安装完成后设置
$ echo 'export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.ustc.edu.cn/homebrew-bottles/bottles' >> ~/.zprofile
$ source ~/.zprofile
# 执行第二步时会需要安装一个xcode组件,需留意终端内反馈的信息。

如果已安装需要换源

1
2
3
4
5
6
7
8
 #脚本(清华 macOS zsh)
$ 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

$ echo 'export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.tuna.tsinghua.edu.cn/homebrew-bottles/bottles' >> ~/.zprofile
$ source ~/.zprofile

完成后可使用brew –version查看版本号