安裝(需要 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