brm can help you easy and fast switch between different Homebrew registries, now include: official, tsinghua, aliyun, ustc.
$ npm install -g homebrew-brm
Or
$ yarn global add homebrew-brm
$ brm -h
Usage: brm [options] [command]
Homebrew registry manager for macOS
Options:
-V, --version output the version number
-h, --help output usage information
Commands:
ls List all the registries
current Show current registry and URL
use <registry> Change homebrew registry
test [registry] Show response time for specific or all registries
$ brm ls
ββββββββββββ¬βββββββββββββββββββ¬βββββββββββββββββββ¬βββββββββββββββββββ¬βββββββββββββββββββ
β β brew β homebrew/core β homebrew/cask β homebrew/bottles β
ββββββββββββΌβββββββββββββββββββΌβββββββββββββββββββΌβββββββββββββββββββΌβββββββββββββββββββ€
β official β β β β β β β β β
ββββββββββββΌβββββββββββββββββββΌβββββββββββββββββββΌβββββββββββββββββββΌβββββββββββββββββββ€
β tsinghua β β β β β Use β β β
ββββββββββββΌβββββββββββββββββββΌβββββββββββββββββββΌβββββββββββββββββββΌβββββββββββββββββββ€
β aliyun β Use β Use β β β Use β
ββββββββββββΌβββββββββββββββββββΌβββββββββββββββββββΌβββββββββββββββββββΌβββββββββββββββββββ€
β ustc β β β β β β β β β
ββββββββββββ΄βββββββββββββββββββ΄βββββββββββββββββββ΄βββββββββββββββββββ΄βββββββββββββββββββ
$ brm use ustc
? Select registry (Press <space> to select, <a> to toggle all, <i> to invert selection)
β―β brew
β homebrew/core
β homebrew/cask
β homebrew/bottles
$ brm use ustc
? Select registry brew, homebrew/core, homebrew/bottles
[BRM] Set brew registry to https://mirrors.ustc.edu.cn/brew.git
[BRM] Set homebrew/core registry to https://mirrors.ustc.edu.cn/homebrew-core.git
[BRM] Set homebrew/cask registry to https://mirrors.ustc.edu.cn/homebrew-cask.git
[BRM] Set homebrew/bottles registry to https://mirrors.ustc.edu.cn/homebrew-bottles
[BRM] Executing brew cleanup
[BRM] Executing brew update
Already up-to-date.
[BRM] Done.
$ brm current
ββββββββββββββββββββ¬βββββββββββ¬ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β brew β aliyun β https://mirrors.aliyun.com/homebrew/brew.git β
ββββββββββββββββββββΌβββββββββββΌββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β homebrew/core β aliyun β https://mirrors.aliyun.com/homebrew/homebrew-core.git β
ββββββββββββββββββββΌβββββββββββΌββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β homebrew/cask β tsinghua β https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/homebrew-cask.git β
ββββββββββββββββββββΌβββββββββββΌββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β homebrew/bottles β aliyun β https://mirrors.aliyun.com/homebrew/homebrew-bottles β
ββββββββββββββββββββ΄βββββββββββ΄ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
$ brm
[BRM][WARN] Missing dependency - Homebrew
? Press <Enter> to install Homebrew? Yes
$ brm test aliyun
[BRM] Testing speed of aliyun...
aliyun ------------------------ 10 ms
$ brm test
[BRM] Testing speed of official, tsinghua, aliyun, ustc...
aliyun ------------------------ 18 ms
tsinghua ---------------------- 33 ms
ustc -------------------------- 45 ms
official ---------------------- timeout