Homebrew能夠簡單理解爲在Mac上用命令行安裝軟件的工具.git
brew install FORMULA...
.Formula
的快,也是默認的安裝軟件方式.配方Formula
,/usr/local/Homebrew/Library/Taps/homebrew/homebrew-core
.配方
,/usr/local/Homebrew/Library/Taps/homebrew/homebrew-cask
.系統版本: macOS Catalina 10.15.2github
1.安裝Homebrew,目前官方最新版的安裝方法已由原先的ruby腳本換成bash腳本了shell
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"
2.使用國內鏡像源swift
homebrew-core
倉庫也克隆到了本地,那麼只需更改本地brew
庫(Homebrew軟件自身)的homebrew-core
庫的遠程源地址便可# 簡單比較過中科大的源和清華的源,前者更快,這裏使用的是中科大提供的源 # 2.1 替換brew.git: cd "$(brew --repo)" git remote set-url origin https://mirrors.ustc.edu.cn/brew.git # 2.2 替換homebrew-core.git: cd "$(brew --repo)/Library/Taps/homebrew/homebrew-core" git remote set-url origin https://mirrors.ustc.edu.cn/homebrew-core.git # 2.3 替換bottles源,macOS使用的是 zsh 的shell, 可執行`echo $0`查看當前的shell工具類型 echo 'export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.ustc.edu.cn/homebrew-bottles' >> ~/.zshrc source ~/.zshrc
homebrew-core
倉庫克隆失敗的,須要手動克隆到本地:
即把上面一條中的2.2 替換homebrew-core.git
一步改爲直接克隆到本地ruby
# shell執行 git clone https://mirrors.ustc.edu.cn/homebrew-core.git /usr/local/Homebrew/Library/Taps/homebrew/homebrew-core
到這裏Homebrew已經能夠使用了.bash
3.cask源配置(選配,在安裝圖形界面軟件時須要)
執行brew tap
查看下載到本地的倉庫,若是 cask* 的都有則能夠將其git的遠程源替換成國內的
curl
# shell執行 git -C "$(brew --repo homebrew/cask)" remote set-url origin https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/homebrew-cask.git git -C "$(brew --repo homebrew/cask-fonts)" remote set-url origin https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/homebrew-cask-fonts.git git -C "$(brew --repo homebrew/cask-drivers)" remote set-url origin https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/homebrew-cask-drivers.git
不然,直接將清華源的倉庫克隆到本地工具
# shell執行 git clone https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/homebrew-cask.git /usr/local/Homebrew/Library/Taps/homebrew/homebrew-cask git clone https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/homebrew-cask-fonts.git /usr/local/Homebrew/Library/Taps/homebrew/homebrew-cask-fonts git clone https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/homebrew-cask-drivers.git /usr/local/Homebrew/Library/Taps/homebrew/homebrew-cask-drivers
# 搜索是否有這個軟件 brew search wget # 安裝 brew install wget
brew cask install atom
(上圖來自官方git倉庫中的readme)post
若有紕漏,歡迎留言補充.atom