Homebrew安裝和簡(jiǎn)單使用

Homebrew 是一款 macOS 平臺(tái)下的軟件包管理工具,擁有安裝、卸載、更新、查看、搜索等很多實(shí)用的功能。包管理工具可以讓你安裝和更新程序變得更方便,目前在 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
長(zhǎng)期更換
echo 'export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.tuna.tsinghua.edu.cn/homebrew-bottles' >> ~/.bash_profile
source ~/.bash_profile
臨時(shí)更換
export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.tuna.tsinghua.edu.cn/homebrew-bottles

注釋掉bash配置文件里的有關(guān)Homebrew Bottles即可恢復(fù)官方源。 重啟bash或讓bash重讀配置文件。


參考1 參考2

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀(guān)點(diǎn),簡(jiǎn)書(shū)系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

推薦閱讀更多精彩內(nèi)容