brew安装及常用命令
安装
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
https://brew.idayer.com/
查看镜像源
#brew.git镜像源
git -C "(brew --repo)" remote -v
#homebrew-core.git镜像源
git -C "(brew --repo homebrew/core)" remote -v
#homebrew-cask.git镜像源
git -C "$(brew --repo homebrew/cask)" remote -v
国内镜像地址
中科大:https://mirrors.ustc.edu.cn
清华:https://mirrors.tuna.tsinghua.edu.cn/git/homebrew
阿里云:https://mirrors.aliyun.com/homebrew
替换镜像源
#替换 Homebrew
git -C "(brew --repo)" remote set-url origin https://mirrors.aliyun.com/homebrew/brew.git
#替换 Homebrew Core
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
echo 'export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.aliyun.com/homebrew/homebrew-bottles' >> ~/.bash_profile
或
# HomeBrew
export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.aliyun.com/homebrew/homebrew-bottles
export PATH="/usr/local/bin:PATH"
export PATH="/usr/local/sbin:PATH"
# HomeBrew END
source ~/.bash_profile
echo 'export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.aliyun.com/homebrew/homebrew-bottles' >> ~/.zshrc
或
# HomeBrew
export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.aliyun.com/homebrew/homebrew-bottles
export PATH="/usr/local/bin:PATH"
export PATH="/usr/local/sbin:$PATH"
# HomeBrew END
source ~/.zshrc
brew update
还原官方源
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
# 找到 ~/.bash_profile 或者 ~/.zshrc 中的HOMEBREW_BOTTLE_DOMAIN 一行删除
brew update
常用命令
帮助
brew help
版本信息
brew -v
安装包
brew install wget
卸载包
brew uninstall wget
更新
brew update
查询可更新的包
brew outdated
更新包
brew upgrade
更新指定包
brew upgrade wget
清理
//清理所有包的旧版本
brew cleanup
//清理指定包的旧版本
brew cleanup [包名]
//查看可清理的旧版本包,不执行实际操作
brew cleanup -n
查看包信息
brew info [包名]
查看安装列表
brew list
搜索包
brew search [包名]