【 Homebrew series 】

  1. HomeBrew regular use tutorial
  2. Homebrew进阶使用教程(一)
  3. Homebrew Advanced Tutorial 2 – Build your own repository with a command line weather client
  4. Install and connect to Homebrew on MAC

I lot address: making address: https://github.com/rangaofei/homebrew-saka

Replace domestic source

He wrote an installation script to choose domestic source when installation: making address: https://github.com/rgf456/HomebrewInstall based on the official script to modify:

1. Start the iterm terminal and run the following command:

/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/rgf456/HomebrewInstall/master/install.rb)"
Copy the code

The script is automatically executed and the following output is displayed:

 ~ / / usr/bin/ruby-e "$(curl -fsSL https://raw.githubusercontent.com/rgf456/HomebrewInstall/master/install.rb)"Please input you want to select the source of 0. HomeBrew official mirror: the brew: https://github.com/Homebrew/brew core: 1 at https://github.com/Homebrew/homebrew-core. Tsinghua university image: brew: https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/brew.git core: https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/homebrew-core.git 2. USTC mirror: brew: https://mirrors.ustc.edu.cn/brew.git core: https://mirrors.ustc.edu.cn/homebrew-core.git -- -- -- -- -- -- -- -- -- -- -- -- -- please enter 0, select the source address -- -- -- -- -- -- -- -- -- -- -- -- -- --Copy the code

2. Select the corresponding source number and enter the corresponding number to use the corresponding source

0 You select an official mirrorCopy the code

Please ignore the warning

If you enter a number other than 0, 1, or 2, you will be prompted to select official installation by default.

3. Official process

==> 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

Copy the code

Click Enter to wait for the installation to complete

After the installation is complete, perform this operation

cd "$(brew --repo)" 
Copy the code
git remote -v
Copy the code

You can see whether the mirror address is changed:

 ~ /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)
Copy the code

If you do not want to install with my script, but want to specify yourself:

The following is to manually replace the official tutorial of Tsinghua mirror, command line by line can be executed.

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
Copy the code

Find the homebrew cache path

Run the following command

brew --cache
Copy the code

The usual route is ~/Library/Caches/Homebrew

Go directly to the cache path

cd (brew --cache)
Copy the code

At this point, you go directly to the cache directory.

The cache directory can be specified during installation: (Not recommended) Download the installation script first:

https://raw.githubusercontent.com/Homebrew/install/master/install to save the content of the script to call the local install download good after the install script, Find the HOMEBREW_CACHE variable, change it to the folder you want, and run the install command:

/usr/bin/ruby -e "$(cat install)"
Copy the code

Homebrew is ready to install.

Uninstall the homebrew

Run the following command

ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/uninstall)"
Copy the code