macOS 安装 brew 和配置 brew 中国镜像源
安装 brew
https://brew.sh/
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
# 中国镜像
/bin/bash -c "$(curl -fsSL https://ghproxy.com/https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
设置中国镜像
先查看当前使用 zsh
还是 bash
# 查看 SHELL
echo $SHELL
# /bin/zsh
~/.zshrc
# /bin/bash
~/.bash_profile
添加下面的那些配置信息到配置文件。
Homebrew 镜像加速
https://mirrors.ustc.edu.cn/help/brew.git.html
export HOMEBREW_BREW_GIT_REMOTE="https://mirrors.ustc.edu.cn/brew.git"
# 执行更新
brew update
Homebrew Core 镜像加速
https://mirrors.ustc.edu.cn/help/homebrew-core.git.html
export HOMEBREW_CORE_GIT_REMOTE="https://mirrors.ustc.edu.cn/homebrew-core.git"
brew update
# 重置为官方地址
unset HOMEBREW_CORE_GIT_REMOTE
brew tap --custom-remote homebrew/core https://github.com/Homebrew/homebrew-core
Homebrew Bottles 镜像加速
https://mirrors.ustc.edu.cn/help/homebrew-bottles.html
export HOMEBREW_BOTTLE_DOMAIN="https://mirrors.ustc.edu.cn/homebrew-bottles"
export HOMEBREW_API_DOMAIN="https://mirrors.ustc.edu.cn/homebrew-bottles/api"
Homebrew Cask 镜像加速
https://mirrors.ustc.edu.cn/help/homebrew-cask.git.html
brew tap --custom-remote --force-auto-update homebrew/cask https://mirrors.ustc.edu.cn/homebrew-cask.git
# 重置为官方地址
brew tap --custom-remote --force-auto-update homebrew/cask https://github.com/Homebrew/homebrew-cask
Homebrew Cask Versions 镜像加速
https://mirrors.ustc.edu.cn/help/homebrew-cask-versions.git.html
# 使用 USTC 镜像安装,或将已安装的仓库远程替换为 USTC 镜像:
brew tap --custom-remote --force-auto-update homebrew/cask-versions https://mirrors.ustc.edu.cn/homebrew-cask-versions.git
# 重置为官方地址
brew tap --custom-remote --force-auto-update homebrew/cask-versions https://github.com/Homebrew/homebrew-cask-versions