1. Homebrew是什么? Homebrew能做什么?

Homebrew是Mac下神一样的软件管理工具.

Homebrew几乎安装任何你想到的开源软件(没有界面Gui的, 有界面的)

Homebrew同样支持相当多的商业应用安装, 像jetbrains IDEA全家桶, 网易云音乐 QQ也都支持.

2. Homebrew 安装

打开终端Terminal, 输入下面命令即可.

/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"

3. Homebrew 使用.

3.1 brew install –cask与brew install合并为brew install.

brew install 可安装有界面或无界面的软件与应用.

# 搜索软件
brew search git
brew search google-chrome

# 安装
brew install vim
brew install neteasemusic

# 重新安装
brew reinstall vim
brew reinstall neteasemusic

# 升级软件
brew upgrade curl
brew upgrade google-chrome

# 不升级软件
brew pin curl

# 卸载软件与应用
brew uninstall git
brew uninstall  QQ

# 查看软件与应用
brew info git
brew info sourcetree
brew list

# 启动软件
brew services start mariadb

# 重新启动软件
brew services restart nginx

# 关闭软件
brew services stop mariadb

3.2 使用别名, 更快速, 下面别名写~/.zshrc或~/.bashrc中, source ~/.zshrc或.bashrc重新生效.

alias bsearch='brew search'
alias binstall='brew install'
alias buninstall='brew uninstall'
alias bupdate='brew update'
alias blist='brew list'
alias boutdated='brew outdated'
alias breinstall='brew reinstall'
alias bupgrade='brew upgrade'
alias bremove='brew remove'
alias binfo='brew info'

alias bservices='brew services'
alias bstart='brew services start'
alias bsrestart='brew services restart'
alias bstop='brew services stop'
alias bslist='brew services list'
alias bcua='brew cu -a'

3.3 查看所有有界面Gui可更新软件.

brew tap buo/cask-upgrade
brew cu -a

选择Y更新所有, 也可brew upgrade visual-studio-code, 更新指定软件

brew-cask-upgrade

4. Homebrew安装指定版本的软件.

4.1 使用brew info查看软件信息

brew info vim

vim

4.2 访问来源, https://github.com/Homebrew/homebrew-core/blob/HEAD/Formula/vim.rb

4.3 查看历史信息

vim

4.4 显示历史信息, 点击需要安装的vim版本, 8.2.3100

vim

4.5 根据当前系统找到对应sha256, 复制

vim

4.6 安装, 拼接出地址, 直接安装.

brew install https://raw.githubusercontent.com/Homebrew/homebrew-core/f73c37f7282bf9c542aeba15b4ae7862cb65c757ed455594eecc5ced52bb307d/Formula/vim.rb