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 dockerCask
Homebrew Cask用于安装macOS图形界面应用:
brew install --cask <application>
brew install --cask firefox docker macdown相关页面
- Homebrew安装指南 — 清华源镜像配置
- Mac终端配置 — 使用 brew 安装 fzf 增强 Ctrl+R
- tmux — 可通过
brew install tmux安装 - iTerm2 — 可通过
brew install --cask iterm2安装
参考
- 官网: brew.sh
- 中文镜像: mirrors.tuna.tsinghua.edu.cn