macos zsh 切换 Homebrew 为清华源

2025年6月26日 9点热度 0人点赞 0条评论

复制下面的整段代码粘贴进终端直接运行:

# 设置 Homebrew 源为清华镜像
echo "正在切换 Homebrew 源为清华镜像..."

# 替换 brew 本体源
cd "$(brew --repo)" && \
git remote set-url origin https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/brew.git

# 替换 homebrew-core 源
cd "$(brew --repo homebrew/core)" && \
git remote set-url origin https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/homebrew-core.git

# 替换 homebrew-cask 源(可选)
cd "$(brew --repo homebrew/cask)" && \
git remote set-url origin https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/homebrew-cask.git

# 设置 bottles 镜像
echo 'export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.tuna.tsinghua.edu.cn/homebrew-bottles' >> ~/.zshrc
source ~/.zshrc

# 更新 brew
brew update

echo "✅ Homebrew 镜像源已成功切换为清华源!"

本文链接:https://www.aiunk.com/61262/

“我们没有相见,却是此刻最好的相聚。”

—— 未知《日食记》