Homebrew 安装以及更新源替换

安装xcode

如果安装app store里面的xcode,会发现很大(6G多)
在终端执行:

xcode-select --install

如果没有安装过xcode,会弹出个窗口,点击安装即可,如下图:

在这里插入图片描述

安装后再重新执行xcode-select --install会出现如下结果:
在这里插入图片描述

Homebrew 安装

/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

在这里插入图片描述
在不翻墙的情况下,安装可能有些慢。

Homebrew 更新源

当使用Homebrew下载应用时,会发现很慢,可以换成国内的更新源。

Homebrew的更新源由三部分组成:本体(brew.git)、核心(homebrew-core.git)以及二进制预编译包(homebrew-bottles),需要对这个三个部分,分别进行设置。

# 替换brew.git:
$ cd "$(brew --repo)"
# 中国科大:
$ git remote set-url origin https://mirrors.ustc.edu.cn/brew.git
# 清华大学:
$ git remote set-url origin https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/brew.git

# 替换homebrew-core.git:
$ cd "$(brew --repo)/Library/Taps/homebrew/homebrew-core"
# 中国科大:
$ git remote set-url origin https://mirrors.ustc.edu.cn/homebrew-core.git
# 清华大学:
$ git remote set-url origin https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/homebrew-core.git

# 替换homebrew-bottles:
# 中国科大:
$ echo 'export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.ustc.edu.cn/homebrew-bottles' >> ~/.bash_profile
$ source ~/.bash_profile
# 清华大学:
$ echo 'export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.tuna.tsinghua.edu.cn/homebrew-bottles' >> ~/.bash_profile
$ source ~/.bash_profile

# 应用生效:
$ brew update

更新源完成后,下载应用时,会显示更新源的地址,如下图所示:
在这里插入图片描述

参考链接

最后的最后

有啥问题,欢迎进群交流技术: 363034250