Homebrew是什么
- Homebrew是一款Mac
OS平台下的软件包管理工具,拥有安装、卸载、更新、查看、搜索等很多实用的功能。简单的一条指令,就可以实现包管理,无需关心各种依赖和文件路径的情况,十分方便快捷。
Homebrew的安装和卸载
- 在命令行中执行以下命令
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
- 卸载Homebrew
$ cd `brew --prefix`
$ rm -rf Cellar
$ brew prune
$ rm `git ls-files`
$ rm -r Library/Homebrew Library/Aliases Library/Formula Library/Contributions
$ rm -rf .git
$ rm -rf ~/Library/Caches/Homebrew
Homebrew常用命令
- 安装软件
brew install 软件名称
- 卸载软件
brew uninstall 软件名称
- 查询软件
brew search 软件名称
- 列出所有已安装的软件
brew list
- 更新Homebrew
brew update
- 更新软件
brew upgrade 软件名
- 查看软件信息
brew info 软件名称
- 查看软件的依赖包
brew deps
- 查看Homebrew是否正常运行
brew doctor
- 查看Homebrew版本信息
brew -v
更新Homebrew数据源
$ cd "$(brew --repo)"
$ git remote set-url origin https://mirrors.ustc.edu.cn/brew.git
$ git remote set-url origin https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/brew.git
$ cd "$(brew --repo)/Library/Taps/homebrew/homebrew-core"
$ git remote set-url origin https://mirrors.ustc.edu.cn/homebrew-core.git
$ git remote set-url origin https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/homebrew-core.git
$ echo 'export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.ustc.edu.cn/homebrew-bottles' >> ~/.bash_profile
$ source ~/.bash_profile
$ echo 'export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.tuna.tsinghua.edu.cn/homebrew-bottles' >> ~/.bash_profile
$ source ~/.bash_profile
$ brew update
重置Homebrew数据源
$ 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