mac 下 brew安装和使用
- 安装brew
/bin/bash -c "$(curl -fsSL https://gitee.com/ineo6/homebrew-install/raw/master/install.sh)"
- 将homebrew添加到path中
echo 'eval "$(/opt/homebrew/bin/brew shellenv)"' >> /Users/jackhou/.zprofile
eval "$(/opt/homebrew/bin/brew shellenv)"
- 把brew下载包的地址切换为国内的镜像地址
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 update
- 设置bottles镜像
echo 'export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.ustc.edu.cn/homebrew-bottles/bottles' >> ~/.zprofile
source ~/.zprofile
brew 常用命令
brew -v
brew update
brew -help
brew outdated
brew upgrade [包名]
例:brew upgrade git
brew upgrade
brew install [包名]@版本
例:brew install git
brew uninstall [包名]
例:brew uninstall git
brew cleanup
例:brew cleanup -n
例:brew cleanup -s
例:brew cleanup --prune=1
brew cleanup [包名]
例:brew cleanup git
brew outdated
brew cleanup -n
brew pin $FORMULA
brew unpin $FORMULA
brew info [包名]
例:brew info git
brew list
brew search [包名]
例:brew search git
brew deps [包名]
例: brew deps git
$ sudo brew update
$ sudo chown -R $USER /usr/local
例:$ sudo chown -R lean /usr/local
<install path> -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"