1.Homebrew安装
1.1. 官方镜像源安装
Homebrew安装脚本执行
# 安装Homebrew
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
# 配置环境变量
echo 'eval "$(/opt/homebrew/bin/brew shellenv)"' >> ~/.zprofile
source ~/.zprofile
Homebrew 设置国内源
# 替换源
git -C "$(brew --repo)" remote set-url origin https://mirrors.ustc.edu.cn/brew.git
git -C "$(brew --repo homebrew/core)" remote set-url origin https://mirrors.ustc.edu.cn/homebrew-core.git
git -C "$(brew --repo homebrew/cask)" remote set-url origin https://mirrors.ustc.edu.cn/homebrew-cask.git
# 替换 brew bintray 镜像
echo 'export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.ustc.edu.cn/homebrew-bottles' >> ~/.zshrc
source ~/.zshrc
# 刷新
$ brew update
1.2. 国内第三方源安装
- Homebrew安装脚本执行,国内的安装时,会提示选择brew的镜像源
# 安装Homebrew
/bin/zsh -c "$(curl -fsSL https://gitee.com/cunkai/HomebrewCN/raw/master/Homebrew.sh)"
# 使安装时的环境变量生效
source ~/.zprofile
1.3. Homebrew的使用
brew update # 更新
brew upgrade # 升级
brew search <软件名> #搜索软件
brew install <软件名> # 安装软件
brew list # 列举安装了的软件
brew uninstall <软件名> # 卸载软件
brew install telnet
➜ ~ brew list
==> Formulae
autojump minikube screenresolution
ca-certificates mpdecimal sqlite
docker neofetch sqlmap
docker-completion openssl@3 telnet
docker-compose python@3.11 tree
jenv python@3.12 xz
kubernetes-cli readline