🚀 一键安装脚本
/bin/bash -c "$(curl -fsSL https://gitee.com/ineo6/homebrew-install/raw/master/install.sh)"
🔄 镜像源切换
🎓 清华镜像源
# 切换brew核心仓库
git -C "$(brew --repo)" remote set-url origin https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/brew.git
# 切换homebrew-core
git -C "$(brew --repo homebrew/core)" remote set-url origin https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/homebrew-core.git
# 切换homebrew-cask
git -C "$(brew --repo homebrew/cask)" remote set-url origin https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/homebrew-cask.git
🍼 Bintray镜像配置
# 设置环境变量
echo 'export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.tuna.tsinghua.edu.cn/homebrew-bottles' >> ~/.zshrc
echo 'export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.tuna.tsinghua.edu.cn/homebrew-bottles' >> ~/.bash_profile
# 立即生效
source ~/.bash_profile
🔄 刷新源缓存
brew update
⏮️ 恢复默认配置
# 恢复官方仓库
git -C "$(brew --repo)" remote set-url origin https://github.com/Homebrew/brew.git
git -C "$(brew --repo homebrew/core)" remote set-url origin https://github.com/Homebrew/homebrew-core.git
git -C "$(brew --repo homebrew/cask)" remote set-url origin https://github.com/Homebrew/homebrew-cask
# 清除镜像配置
export HOMEBREW_BOTTLE_DOMAIN=
sed -i '' '/^export HOMEBREW_BOTTLE_DOMAIN/ s/^/#/' ~/.bash_profile
sed -i '' '/^export HOMEBREW_BOTTLE_DOMAIN/ s/^/#/' ~/.zshrc
# 更新
brew update
🌐 其他国内镜像源
- 阿里云镜像: https://developer.aliyun.com/mirror/homebrew/
- 腾讯云镜像: https://mirrors.cloud.tencent.com/help/homebrew.html