Brew

change mirrors

brew.git

# brew.git
cd "$(brew --repo)"
git remote set-url origin https://mirrors.ustc.edu.cn/brew.git
 
# revert changes
cd "$(brew --repo)"
git remote set-url origin https://github.com/Homebrew/brew.git

homebrew-core.git

# homebrew-core.git
cd "$(brew --repo)/Library/Taps/homebrew/homebrew-core"
git remote set-url origin https://mirrors.ustc.edu.cn/homebrew-core.git
 
# revert changes
cd "$(brew --repo)/Library/Taps/homebrew/homebrew-core"
git remote set-url origin https://github.com/Homebrew/homebrew-core.git

homebrew-bottles

Add this line to ~/.zshrc file

export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.ustc.edu.cn/homebrew-bottles

then

source ~/.zshrc

reference

proxy functions

Add these functions to ~/.zshrc file:

function proxy_off() {
  unset http_proxy
  unset https_proxy
  echo "proxy turned off"
}
 
function proxy_on() {
  export no_proxy="localhost,127.0.0.1"
  export http_proxy="socks5://127.0.0.1:7891"
  export https_proxy=$http_proxy
  echo "proxy turned on"
}
 
function proxy_status() {
  echo $https_proxy
  curl cip.cc
}

Change 7891 to the port number of system proxy.