Mac Homebrew安裝及鏡像替換

[toc]

一、Homebrew的安裝

命令1(這個(gè)命令不好使會(huì)報(bào)錯(cuò),如果報(bào)錯(cuò)嘗試使用命令2或手動(dòng)進(jìn)行鏡像更換):

/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

命令2(這是一個(gè)腳本,同樣可以安裝Homebrew):

 /bin/zsh -c "$(curl -fsSL https://gitee.com/cunkai/HomebrewCN/raw/master/Homebrew.sh)"

使用命令2會(huì)自動(dòng)出現(xiàn)鏡像國(guó)內(nèi)配置選擇,如下


image.png

二、國(guó)內(nèi)鏡像源替換或重置

查看當(dāng)前Homebrew 鏡像源


#brew.git鏡像源
git -C "$(brew --repo)" remote -v

#homebrew-core.git鏡像源
git -C "$(brew --repo homebrew/core)" remote -v

#homebrew-cask.git鏡像源
git -C "$(brew --repo homebrew/cask)" remote -v


國(guó)內(nèi)鏡像地址

科大真香實(shí)例:

#替換 Homebrew
git -C "$(brew --repo)" remote set-url origin https://mirrors.ustc.edu.cn/brew.git

#替換 Homebrew Core
git -C "$(brew --repo homebrew/core)" remote set-url origin https://mirrors.ustc.edu.cn/homebrew-core.git

#替換 Homebrew Cask
git -C "$(brew --repo homebrew/cask)" remote set-url origin https://mirrors.ustc.edu.cn/homebrew-cask.git

#替換 Homebrew-bottles

如果需要恢復(fù)原有鏡像源的話(國(guó)內(nèi)鏡像源突然不能用了或版本不夠新)

git -C "$(brew --repo)" remote set-url origin https://github.com/Homebrew/brew.git

git -C "$(brew --repo homebrew/core)" remote set-url origin https://github.com/Homebrew/homebrew-core.git

git -C "$(brew --repo homebrew/cask)" remote set-url origin https://github.com/Homebrew/homebrew-cask.git

#找到 ~/.bash_profile 或者 ~/.zshrc 中的HOMEBREW_BOTTLE_DOMAIN 一行刪除

brew update

三、Homebrew的使用

1.查看Homebrew命令:brew help
2.安裝任意包:brew install <packageName>,eg:brew install node
3.卸載任意包:brew uninstall <packageName>,eg:brew uninstall git
4.查詢可用包:brew search <packageName>
5.查詢已安裝包列表:brew list
6.查看任意包信息:brew info <packageName>
7.更新Homebrew:brew update
8.Homebrew幫助信息:brew -h
8.查看brew版本:brew -v
10.更新brew版本:brew update
11.整理重復(fù)語句:open ~/.zshrc -e、open ~/.bash_profile -e

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡(jiǎn)書系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容