Skip to content

Set Up Proxy for Programming

Brew

change mirrors

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

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

then

Terminal window
source ~/.zshrc

read more

proxy functions

Add these functions to ~/.zshrc file:

Terminal window
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.