阿里云镜像:
# 配置 Homebrew 核心镜像
git -C "$(brew --repo)" remote set-url origin https://mirrors.aliyun.com/homebrew/brew.git
# 配置 Homebrew 公式镜像
git -C "$(brew --repo homebrew/core)" remote set-url origin https://mirrors.aliyun.com/homebrew/homebrew-core.git
# 配置 Homebrew cask 镜像
git -C "$(brew --repo homebrew/cask)" remote set-url origin https://mirrors.aliyun.com/homebrew/homebrew-cask.git
# 配置 Homebrew Bottles 镜像
export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.aliyun.com/homebrew-bottles
中科大镜像:
# 配置 Homebrew 核心镜像
git -C "$(brew --repo)" remote set-url origin https://mirrors.ustc.edu.cn/brew.git
# 配置 Homebrew 公式镜像
git -C "$(brew --repo homebrew/core)" remote set-url origin https://mirrors.ustc.edu.cn/homebrew-core.git
# 配置 Homebrew cask 镜像
git -C "$(brew --repo homebrew/cask)" remote set-url origin https://mirrors.ustc.edu.cn/homebrew-cask.git
# 配置 Homebrew Bottles 镜像
export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.ustc.edu.cn/homebrew-bottles
清华大学镜像:
# 配置 Homebrew 核心镜像
git -C "$(brew --repo)" remote set-url origin https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/brew.git
# 配置 Homebrew 公式镜像
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
# 配置 Homebrew Bottles 镜像
export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.tuna.tsinghua.edu.cn/homebrew-bottles
查看配置
brew config
更新Homebrew
# 更新
$ brew update
# 升级到最新的 Homebrew
$ brew upgrade
常用命令
# 搜索软件包
brew search package_name
# 安装软件包
brew install package_name
# 卸载软件包
brew uninstall package_name
# 查看已安装的软件包
brew list
# 清理过期的软件包
brew cleanup # 清理所有包的旧版本
brew cleanup [FORMULA ...] # 清理指定包的旧版本
brew cleanup -n # 查看可清理的旧版本包,不执行实际操作
默认配置(官网源)
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.git
export HOMEBREW_BOTTLE_DOMAIN=https://homebrew.bintray.com