安装(需要 Ruby)
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
# 另一个资源,没有试过是否可用
ruby -e "$(curl -fsSL https://raw.github.com/Homebrew/homebrew/go/install)"
搜索
brew search <xxx>
查询
brew info <xxx> # 主要看具体的信息,比如目前的版本,依赖,安装后注意事项等
更新
brew update # 更新 Homebrew 自己,并且使得接下来的两个操作有意义!
检查是否有新版本
brew outdated # 列出所有已安装软件中可以升级的那些
升级
brew upgrade # 升级所有可以升级的软件
清理
brew cleanup # 清理不需要的版本及其安装包缓存
常用的就这些。
一般来说如果你追求新版本,那么你最常用的操作应该如下:
brew update # 更新 Homebrew
brew outdated # 查看哪些软件可升级
#if (升级指定的xxx软件)
brew upgrade <xxx>
#else if (全部升级,升级完然后清理干净)
brew upgrade
brew cleanup
#end
常用命令总结
brew list # 查看已经安装的包
brew update # 更新Homebrew自身
brew doctor # 诊断关于Homebrew的问题(Homebrew 有问题时请用它)
brew cleanup # 清理老版本软件包或者无用的文件
brew show ${formula} # 查看包信息
brew search ${formula} # 按名称搜索
brew upgrade ${formula} # 升级软件包
brew install ${formula} # 按名称安装
brew uninstall ${formula} # 按名称卸载
brew pin/unpin ${formula} # 锁定或者解锁软件包版本,防止误升级
更换Homebrew源
1. 替换brew.git
cd "$(brew --repo)"
git remote set-url origin https://mirrors.aliyun.com/homebrew/brew.git
2. 替换homebrew-core.git
cd "$(brew --repo)/Library/Taps/homebrew/homebrew-core"
git remote set-url origin https://mirrors.aliyun.com/homebrew/homebrew-core.git
3. 替换homebrew-bottles
echo 'export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.aliyun.com/homebrew/homebrew-bottles' >> ~/.zshrc
source ~/.zshrc
4. 替换homebrew-cask.git
cd "$(brew --repo)"/Library/Taps/homebrew/homebrew-cask
git remote set-url origin https://mirrors.ustc.edu.cn/homebrew-cask.git
官方源地址:
https://github.com/Homebrew/brew.git
https://github.com/Homebrew/homebrew-core.git
https://github.com/Homebrew/homebrew-cask
镜像:
Coding:
https://git.coding.net/homebrew/homebrew.git
清华:
https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/brew.git
中科大:
https://mirrors.ustc.edu.cn/brew.git