Homebrew 是一款 macOS 平臺下的軟件包管理工具,擁有安裝、卸載、更新、查看、搜索等很多實用的功能。包管理工具可以讓你安裝和更新程序變得更方便,目前在 OS X 系統(tǒng)中最受歡迎的包管理工具就是 Homebrew。
安裝和卸載
- 安裝
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
- 卸載
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/uninstall)"
常用命令:
安裝軟件:
brew install <packageName>
卸載軟件:brew uninstall <packageName>
搜索軟件:brew search <packageName>
更新軟件:brew upgrade <packageName>
查看安裝列表:brew list
更新Homebrew:brew update
查看包信息:brew info <packageName>
查看Homebrew版本:brew -v
替換及重置homebrew默認(rèn)源
- 替換
//替換brew.git:
cd "$(brew --repo)"
git remote set-url origin https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/brew.git
//替換homebrew-core.git:
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
- 重置
//重置brew.git:
cd "$(brew --repo)"
git remote set-url origin https://github.com/Homebrew/brew.git
//重置homebrew-core.git:
cd "$(brew --repo)/Library/Taps/homebrew/homebrew-core"
git remote set-url origin https://github.com/Homebrew/homebrew-core.git
brew update
- 更換homebrew-bottles
長期更換
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
注釋掉bash配置文件里的有關(guān)Homebrew Bottles即可恢復(fù)官方源。 重啟bash或讓bash重讀配置文件。