A, the official
1, the premise
- Prerequisites for installing Homebrew on Mac:
- 64bit Intel CPU or Apple Silicon CPU (M1)
- MacOS Mojave (10.14) or later
- Install Xcode Command Line Tools for Xcode
- You can do it from the command line
xcode-select --install
The installation
- You can do it from the command line
- Shell (such as bash or ZSH)
2, installation,
- Open the terminal and enter the following command:
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
Copy the code
Other installation methods
- Due to network problems in China, the installation may fail using the official installation method. You can try other installation methods that are more suitable for the domestic network environment. Please refer to brew.idayer.com/.
1. Install HomebreW-Core
/bin/bash -c "$(curl -fsSL https://cdn.jsdelivr.net/gh/ineo6/homebrew-install/install.sh)"
Copy the code
2. Install HomebreW-Cask
cd "$(brew --repo)/Library/Taps/homebrew/"
Copy the code
git clone https://mirrors.ustc.edu.cn/homebrew-cask.git
Copy the code
Third, the source
- To speed up the process of installing other software using Homebrew, it is recommended that the software source be set to a domestic source.
1. View the source
cd "$(brew --repo)" && git remote -v
Copy the code
cd "$(brew --repo homebrew/core)" && git remote -v
Copy the code
cd "$(brew --repo homebrew/cask)" && git remote -v
Copy the code
2. Set the source
- Set to the source of USTC
git -C "$(brew --repo)" remote set-url origin https://mirrors.ustc.edu.cn/brew.git
Copy the code
git -C "$(brew --repo homebrew/core)" remote set-url origin https://mirrors.ustc.edu.cn/homebrew-core.git
Copy the code
git -C "$(brew --repo homebrew/cask)" remote set-url origin https://mirrors.ustc.edu.cn/homebrew-cask.git
Copy the code
brew update
Copy the code
3, set a bottle mirror
- Starting with macOS Catalina(10.15.x) for Mac use
zsh
As the default shell, the configuration file used is:.zprofile
echo 'export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.ustc.edu.cn/homebrew-bottles' >> ~/.zprofile
Copy the code
source ~/.zprofile
Copy the code
- If it is a previous version of macOS, Mac is used
bash
As the default shell, the configuration file used is:.bash_profile
echo 'export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.ustc.edu.cn/homebrew-bottles' >> ~/.bash_profile
Copy the code
source ~/.bash_profile
Copy the code
4. Reset to official source
git -C "$(brew --repo)" remote set-url origin https://github.com/Homebrew/brew.git
Copy the code
git -C "$(brew --repo homebrew/core)" remote set-url origin https://github.com/Homebrew/homebrew-core.git
Copy the code
git -C "$(brew --repo homebrew/cask)" remote set-url origin https://github.com/Homebrew/homebrew-cask.git
Copy the code
# ZSH comment out HOMEBREW_BOTTLE_DOMAIN configuration
vi ~/.zprofile
# export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.ustc.edu.cn/homebrew-bottles
source ~/.zprofile
Copy the code
# bash comment out the HOMEBREW_BOTTLE_DOMAIN configuration
vi ~/.bash_profile
# export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.ustc.edu.cn/homebrew-bottles
source ~/.bash_profile
Copy the code
brew update
Copy the code
Four, unloading
/usr/bin/ruby -e "$(curl -fsSL https://cdn.jsdelivr.net/gh/ineo6/homebrew-install/uninstall)"
Copy the code
Use the uSTC source directly
- To use the uSTC source directly, select (1)
/bin/zsh -c "$(curl -fsSL https://gitee.com/cunkai/HomebrewCN/raw/master/Homebrew.sh)"
Copy the code