🍺 Homebrew (macOS 包管理器) - 中科大镜像配置

复制以下命令到终端执行即可完成配置:

curl -sSL https://mirror2030.com/scripts/homebrew-ustc.sh | bash
✅ 所有脚本开源透明,可在下方查看完整内容

适合想了解具体步骤的用户:

export HOMEBREW_BREW_GIT_REMOTE="https://mirrors.ustc.edu.cn/git/homebrew/brew.git"
export HOMEBREW_CORE_GIT_REMOTE="https://mirrors.ustc.edu.cn/git/homebrew/homebrew-core.git"
brew update

完整脚本内容(可复制保存):

#!/bin/bash
# Homebrew 镜像配置 - 中科大
# 由 镜像加速站 自动生成

echo "正在配置 Homebrew 镜像源..."

# 设置环境变量
export HOMEBREW_BREW_GIT_REMOTE="https://mirrors.ustc.edu.cn/git/homebrew/brew.git"
export HOMEBREW_CORE_GIT_REMOTE="https://mirrors.ustc.edu.cn/git/homebrew/homebrew-core.git"

# 写入 shell 配置文件
if [ -f ~/.zshrc ]; then
    echo 'export HOMEBREW_BREW_GIT_REMOTE="https://mirrors.ustc.edu.cn/git/homebrew/brew.git"' >> ~/.zshrc
    echo 'export HOMEBREW_CORE_GIT_REMOTE="https://mirrors.ustc.edu.cn/git/homebrew/homebrew-core.git"' >> ~/.zshrc
    echo "✓ 已写入 ~/.zshrc"
elif [ -f ~/.bash_profile ]; then
    echo 'export HOMEBREW_BREW_GIT_REMOTE="https://mirrors.ustc.edu.cn/git/homebrew/brew.git"' >> ~/.bash_profile
    echo 'export HOMEBREW_CORE_GIT_REMOTE="https://mirrors.ustc.edu.cn/git/homebrew/homebrew-core.git"' >> ~/.bash_profile
    echo "✓ 已写入 ~/.bash_profile"
fi

# 更新 Homebrew
brew update

echo "\n✅ Homebrew 镜像源已成功配置为 中科大"
echo "重启终端或执行 source ~/.zshrc 以使配置生效"
⬇️ 下载脚本文件

💡 使用提示

  • 配置后请重启终端或运行 source ~/.bashrc
  • 如遇问题可访问 教程中心 查看详细指南
  • 建议定期测速选择最优镜像源
← 返回选择其他镜像源 🏠 返回首页