「这是我参与11月更文挑战的第1天,活动详情查看:2021最后一次更文挑战」
最近发现mac的brew更新东西特慢,原因如下,brew 源为github.com/
为了更高效率的更新及下载,故把brew源改为国内(阿里 或 中科大)的源。
代码如下:记录一下,方便后面自己修改。
查看brew源:
#查看 brew.git 当前源
cd "$(brew --repo)" && git remote -v
#查看 homebrew-core 当前源
cd "$(brew --repo homebrew/core)" && git remote -v
#查看 homebrew-cask 当前源
cd "$(brew --repo homebrew/cask)" && git remote -v
替换为阿里源
# 修改 brew.git 为阿里源
$ git -C "$(brew --repo)" remote set-url origin https://mirrors.aliyun.com/homebrew/brew.git
# 修改 homebrew-core.git 为阿里源
$ git -C "$(brew --repo homebrew/core)" remote set-url origin https://mirrors.aliyun.com/homebrew/homebrew-core.git
# 修改 homebrew-cask.git 为阿里源
$ git -C "$(brew --repo homebrew/cask)" remote set-url origin https://mirrors.aliyun.com/homebrew/homebrew-cask.git
# zsh 替换 brew bintray 镜像
$ echo 'export
HOMEBREW_BOTTLE_DOMAIN=https://mirrors.aliyun.com/homebrew/homebrew-bottles' >> ~/.zshrc
$ source ~/.zshrc
# bash 替换 brew bintray 镜像
$ echo 'export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.aliyun.com/homebrew/homebrew-bottles' >> ~/.bash_profile
$ source ~/.bash_profile
#更新源
brew update
替换为中科大源
# 修改 brew.git 为阿里源
$ git -C "$(brew --repo)" remote set-url origin https://mirrors.ustc.edu.cn/brew.git
# 修改 homebrew-core.git 为阿里源
$ git -C "$(brew --repo homebrew/core)" remote set-url origin https://mirrors.ustc.edu.cn/homebrew-core.git
# 修改 homebrew-cask.git 为阿里源
$ git -C "$(brew --repo homebrew/cask)" remote set-url origin https://mirrors.ustc.edu.cn/homebrew-cask.git
# zsh 替换 brew bintray 镜像
$ echo 'export
HOMEBREW_BOTTLE_DOMAIN=https://mirrors.ustc.edu.cn/homebrew-bottles' >> ~/.zshrc $ source ~/.zshrc
# bash 替换 brew bintray 镜像
$ echo 'export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.ustc.edu.cn/homebrew-bottles' >> ~/.bash_profile
$ source ~/.bash_profile
#更新源
brew update
替换为官方源
# 修改 brew.git 为阿里源
$ git -C "$(brew --repo)" remote set-url origin https://github.com/Homebrew/brew.git
# 修改 homebrew-core.git 为阿里源
$ git -C "$(brew --repo homebrew/core)" remote set-url origin https://github.com/Homebrew/homebrew-core.git
# 修改 homebrew-cask.git 为阿里源
$ git -C "$(brew --repo homebrew/cask)" remote set-url origin https://github.com/Homebrew/homebrew-cask.git
# zsh 替换 brew bintray 镜像
$ echo 'export
HOMEBREW_BOTTLE_DOMAIN=https://github.com/Homebrew/homebrew-bottles' >> ~/.zshrc $ source ~/.zshrc
# bash 替换 brew bintray 镜像
$ echo 'export HOMEBREW_BOTTLE_DOMAIN=https://github.com/Homebrew/homebrew-bottles' >> ~/.bash_profile
$ source ~/.bash_profile
#更新源
brew update