【homebrew 系列文章】git
個人github地址:github地址:https://github.com/rangaofei/homebrew-sakagithub
本身寫了一個安裝時的腳原本在安裝時選擇國內源: github地址:https://github.com/rgf456/HomebrewInstall 基於官方腳本修改:緩存
1.啓動iterm終端,輸入如下命令:ruby
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/rgf456/HomebrewInstall/master/install.rb)"
複製代碼
此時會自動執行腳本,輸出如下內容:bash
~/ /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/rgf456/HomebrewInstall/master/install.rb)"
請輸入您要選擇的源
0.HomeBrew官方鏡像:
brew: https://github.com/Homebrew/brew
core: https://github.com/Homebrew/homebrew-core
1.清華大學鏡像:
brew: https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/brew.git
core: https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/homebrew-core.git
2.中科大鏡像:
brew: https://mirrors.ustc.edu.cn/brew.git
core: https://mirrors.ustc.edu.cn/homebrew-core.git
-------------請輸入0,1,2選擇源地址--------------
複製代碼
2.選擇對應的源編號,輸入對應的數字,便可使用相應的源curl
0
你選擇的是官方鏡像
複製代碼
請忽略警告post
假如輸入的不是0、一、2中的一個數字,則會提示默認選擇官方安裝.fetch
3.官方流程ui
==> This script will install:
/usr/local/bin/brew
/usr/local/share/doc/homebrew
/usr/local/share/man/man1/brew.1
/usr/local/share/zsh/site-functions/_brew
/usr/local/etc/bash_completion.d/brew
/usr/local/Homebrew
Press RETURN to continue or any other key to abort
複製代碼
點擊enter等待安裝完成url
安裝完成後 執行
cd "$(brew --repo)"
複製代碼
git remote -v
複製代碼
便可看到是否更換了鏡像地址:
~/ cd "$(brew --repo)"
/usr/local/Homebrew/ [stable] git remote -v
origin https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/brew.git (fetch)
origin https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/brew.git (push)
rgf456 https://github.com/rgf456/brew (fetch)
rgf456 https://github.com/rgf456/brew (push)
複製代碼
假如不想採用個人腳本安裝,而是想本身指定的話:
如下是手動替換清華鏡像的官方教程,逐條命令行執行便可。
cd "$(brew --repo)"
git remote set-url origin https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/brew.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 --cache
複製代碼
通常狀況下是以下路徑~/Library/Caches/Homebrew
直接進入緩存路徑
cd (brew --cache)
複製代碼
此時直接進入了緩存目錄。
緩存目錄可在安裝時指定:(不建議) 首先下載安裝腳本:
https://raw.githubusercontent.com/Homebrew/install/master/install 將這個腳本內容保存至本地隨便命名install 下載好install腳本後,找到HOMEBREW_CACHE變量,修改成本身想要的文件夾,而後執行安裝命令:
/usr/bin/ruby -e "$(cat install)"
複製代碼
便可安裝homebrew。
執行以下命令
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/uninstall)"
複製代碼