-  一、安装brew/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"二、查看brew版本brew -v brew -v 三、搜索软件命令格式:brew search 软件名 eg: brew search nginx四、安装软件命令格式:brew install 软件名 eg: brew install nginx五、卸载软件命令格式:brew uninstall 软件名 eg: brew uninstall nginx六、查看安装的软件列表brew list七、更新 brewbrew update八、显示软件信息brew info九、显示包依赖brew deps十、确认 brew 是否在正常工作brew doctor十一、配置brew源1、替换成国内中科源:cd "$(brew --repo)" && git remote set-url origin https://mirrors.ustc.edu.cn/brew.githomebrew-core cd "$(brew --repo)/Library/Taps/homebrew/homebrew-core" && git remote set-url origin https://mirrors.ustc.edu.cn/homebrew-core.githomebrew-cask cd "$(brew --repo)/Library/Taps/homebrew/homebrew-cask" && git remote set-url origin https://mirrors.ustc.edu.cn/homebrew-cask.git如果你的Mac使用的是zsh终端,使用如下命令: echo 'export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.ustc.edu.cn/homebrew-bottles' >> ~/.zshrc && source ~/.zshrc如果你的Mac使用的是bash终端,使用如下命令: echo 'export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.ustc.edu.cn/homebrew-bottles' >> ~/.bash_profile && source ~/.bash_profile更新 brew update2、替换成国内阿里源cd "$(brew --repo)" && git remote set-url origin https://mirrors.aliyun.com/homebrew/brew.githomebrew-core cd "$(brew --repo)/Library/Taps/homebrew/homebrew-core" && git remote set-url origin https://mirrors.aliyun.com/homebrew/homebrew-core.githomebrew-cask cd "$(brew --repo)/Library/Taps/homebrew/homebrew-cask" && git remote set-url origin https://mirrors.aliyun.com/homebrew/homebrew-cask.git如果你的Mac使用的是zsh终端,使用如下命令: echo 'export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.aliyun.com/homebrew/homebrew-bottles' >> ~/.zshrc && source ~/.zshrc如果你的Mac使用的是bash终端,使用如下命令: echo 'export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.aliyun.com/homebrew/homebrew-bottles' >> ~/.bash_profile && source ~/.bash_profile更新 brew update十二、还原brew的源cd "$(brew --repo)" && git remote set-url origin https://github.com/Homebrew/brew.gitcd "$(brew --repo)/Library/Taps/homebrew/homebrew-core" && git remote set-url origin https://github.com/Homebrew/homebrew-core.git如果你的Mac使用的是zsh终端,使用如下命令: vim ~/.zshrc # 删除 HOMEBREW_BOTTLE_DOMAIN 配置 source ~/.zshrc如果你的Mac使用的是bash终端,使用如下命令: vim ~/.bash_profile # 删除 HOMEBREW_BOTTLE_DOMAIN 配置 source ~/.bash_profile更新 brew update