-
一、安装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
七、更新 brew
brew update
八、显示软件信息
brew info
九、显示包依赖
brew deps
十、确认 brew 是否在正常工作
brew doctor
十一、配置brew源
1、替换成国内中科源:
cd "$(brew --repo)" && git remote set-url origin https://mirrors.ustc.edu.cn/brew.git
homebrew-core
cd "$(brew --repo)/Library/Taps/homebrew/homebrew-core" && git remote set-url origin https://mirrors.ustc.edu.cn/homebrew-core.git
homebrew-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 update
2、替换成国内阿里源
cd "$(brew --repo)" && git remote set-url origin https://mirrors.aliyun.com/homebrew/brew.git
homebrew-core
cd "$(brew --repo)/Library/Taps/homebrew/homebrew-core" && git remote set-url origin https://mirrors.aliyun.com/homebrew/homebrew-core.git
homebrew-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.git
cd "$(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