Homebrew

概述

Homebrew是macOS最流行的软件包管理器,简化软件安装流程,通过简单命令安装、卸载、更新软件。

核心命令

# 安装软件
brew install <package>
 
# 卸载软件
brew uninstall <package>
 
# 更新软件
brew update && brew upgrade
 
# 搜索软件
brew search <keyword>
 
# 查看已安装
brew list
 
# 清理旧版本
brew cleanup

国内镜像配置

使用清华大学镜像加速(编辑~/.zprofile):

export HOMEBREW_API_DOMAIN="https://mirrors.tuna.tsinghua.edu.cn/homebrew-bottles/api"
export HOMEBREW_BOTTLE_DOMAIN="https://mirrors.tuna.tsinghua.edu.cn/homebrew-bottles"
export HOMEBREW_BREW_GIT_REMOTE="https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/brew.git"
export HOMEBREW_CORE_GIT_REMOTE="https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/homebrew-core.git"
export HOMEBREW_PIP_INDEX_URL="https://pypi.tuna.tsinghua.edu.cn/simple"

Apple Silicon注意

M1/M2/M3/M4 Mac上:

  • Homebrew安装路径: /opt/homebrew
  • 需要手动添加到PATH

常用软件示例

# 开发工具
brew install git node python ruby go
 
# 终端工具
brew install tmux wget curl htop
 
# 图像界面应用
brew install --cask visual-studio-code docker

Cask

Homebrew Cask用于安装macOS图形界面应用:

brew install --cask <application>
brew install --cask firefox docker macdown

相关页面

参考

  • 官网: brew.sh
  • 中文镜像: mirrors.tuna.tsinghua.edu.cn