[TOC]
簡介
- Homebrew是Mac OSX常見的包管理器(命令brew用于命令行工具, brew cask管理帶UI軟件), 類似 ubuntu下apt-get, centOS的yum. 推薦日常Mac下安裝卸載軟件使用.
- 官網(wǎng)
- 基于Ruby的開源工具 github
安裝Homebrew
安裝
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
國內(nèi)源
其實是替換brew/homebrew-core的git遠端倉庫(需要安裝git, 直接brew install git), 替換二進制編譯包環(huán)境變量(homebrew-bottles), 參考清華源
# 替換brew.git
cd "$(brew --repo)"
git remote set-url origin https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/brew.git
# 替換homebrew-core
cd "$(brew --repo)/Library/Taps/homebrew/homebrew-core"
git remote set-url origin https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/homebrew-core.git
# 更新
brew update
# 替換二進制預編譯包
echo 'export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.tuna.tsinghua.edu.cn/homebrew-bottles' >> ~/.bash_profile
source ~/.bash_profile
# 或臨時替換
export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.tuna.tsinghua.edu.cn/homebrew-bottles
使用Homebrew
- 幫助信息:
brew help(-h) - 基本使用
# 更新Homebrew本身, formulae索引等, 需要先安裝git
brew update
# 安裝應用, 例如wget, 安裝到/usr/local/Cellar/wget, ln到/usr/local/bin目錄下
brew install wget
# 安裝帶UI app, 插件, 字體(fonts)及其他非開源應用
brew cask install firefox
# 更新app
brew upgrade git
# 診斷依賴沖突等
brew doctor
# 搜索app
brew search xxx
# 卸載xxx.app
brew uninstall xxx
# 列出安裝的包
brew list
- 其他命令
# 打開包主頁
brew home git
# 查看包信息
brew ino git
# 查看包依賴
brew deps wget #結果顯示gettext libidn2 libunistring openssl
# 清理舊版本
brew cleanup git
brew cleanup
# 顯示是否有新版本可用
brew outdated
# 再來個卸載
brew rm wget # uninstall wget
brew remove -h
卸載Homebrew
cd `brew –prefix`
rm -rf Cellar
brew cleanup
rm -rf Homebrew
rm -rf ~/Library/Caches/Homebrew
如此神器, 你舍得卸載嗎? 我是沒卸載過, 以上卸載步驟僅供參考~~~
Formula
formula: 應用安裝包相關的Ruby腳本文件, 定義Homebrew軟件包, 參考formula
Homebrew formulae are simple Ruby scripts
-- from brew.sh
- 可以自定義formula, see formula cookbook
推薦安裝(updated at 2019-08-13)
# golang
brew install go
# terminal
brew cask install iterm2
# Record and share your terminal
brew install asciinema