N01※更改homebrew镜像源

1> homebrew 安装地址

/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"

2> 替换镜像源

以阿里云的镜像为例

① 替换brew.git

cd "$(brew --repo)"
git remote set-url origin https://mirrors.aliyun.com/homebrew/brew.git

② 替换homebrew-core.git

cd "$(brew --repo)/Library/Taps/homebrew/homebrew-core"
git remote set-url origin https://mirrors.aliyun.com/homebrew/homebrew-core.git

③ 更新brew

brew update

④ 重定向

echo $SHELL    # 看输出结果是/bin/zsh还是/bin/bash

a. /bin/zsh替换homebrew-bottles:

echo 'export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.aliyun.com/homebrew/homebrew-bottles' >> ~/.zshrc
source ~/.zshrc

b. /bin/bash替换homebrew-bottles:

echo 'export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.ustc.edu.cn/homebrew-bottles' >> ~/.bash_profile
source ~/.bash_profile

3> 恢复原来的github镜像

① 恢复brew.git

cd "$(brew --repo)"
git remote set-url origin https://github.com/Homebrew/brew.git

② 恢复homebrew-core.git

cd "$(brew --repo)/Library/Taps/homebrew/homebrew-core"
git remote set-url origin https://github.com/Homebrew/homebrew-core.git

③ 更新brew

brew update

④ 重置homebrew-bottles

echo $SHELL # 看输出结果是/bin/zsh还是/bin/bash

a. /bin/zsh恢复homebrew-bottles:

echo 'export HOMEBREW_BOTTLE_DOMAIN=https://github.com/homebrew/homebrew-bottles' >> ~/.zshrc
source ~/.zshrc

b. /bin/bash恢复homebrew-bottles:

echo 'export HOMEBREW_BOTTLE_DOMAIN=https://github.com/homebrew-bottles' >> ~/.bash_profile
source ~/.bash_profile

4> 去除开始的Updating Homebrew

vim ~/.bash_profile
export HOMEBREW_NO_AUTO_UPDATE=true   # 新增一行

© 版权声明
THE END
喜欢就支持一下吧
点赞2 分享