Setting up proxy for brew/git/pip

Keywords: Programming git brew github pip

1. How to set up HTTP/HTTPS proxy correctly

When brew is set to pass socks5 proxy, it will be found that pip does not support socks5 in fact. It can only pass http/https.

Get port first

  • Click on the status bar of the small rocket
  • HTTP Proxy Preference
  • Get the port number of HTTP (I am 1087)

Add the following to the. bash? Profile /. zshrc (zsh user) and save

#Set up HTTP/HTTPS Proxy
export http_proxy="http://127.0.0.1:1087"; 
export https_proxy="http://127.0.0.1:1087";

Save, enter shell, take zsh for example

#Update configuration
source .zshrc

#Verification
brew update
pip install --upgrade pip

2. How to change the source of brew correctly

There are advantages and disadvantages in setting global proxy or changing source. If you want to change source, try the following steps. Note that you can only choose one of them, otherwise the result is the same.

After the general method is used to replace the source of CUHK, the execution of brew update is still very slow. Later, it is found that the cask is still connected to the github, so we need to replace the cask together. It should be noted that the Git address of Caskroom is from https://github.com/caskroom/h... Moved to https://github.com/Homebrew/h....

Replace the source of China University of science and technology:

# Replace brew.git:
cd "$(brew --repo)"
git remote set-url origin https://mirrors.aliyun.com/homebrew/brew.git

# Replace homebrew-core.git:
cd "$(brew --repo)/Library/Taps/homebrew/homebrew-core"
git remote set-url origin https://mirrors.aliyun.com/homebrew/homebrew-core.git

# Replace homebrew-cask.git:
cd "$(brew --repo)"/Library/Taps/homebrew/homebrew-cask
git remote set-url origin https://mirrors.ustc.edu.cn/homebrew-cask.git

# Replace homebrew bots:
echo 'export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.aliyun.com/homebrew/homebrew-bottles' >> ~/.zshrc
source ~/.bash_profile

Reset official source:

#Reset brew.git:
cd "$(brew --repo)"
git remote set-url origin https://github.com/Homebrew/brew.git

#Reset homebrew-core.git:
cd "$(brew --repo)/Library/Taps/homebrew/homebrew-core"
git remote set-url origin https://github.com/Homebrew/homebrew-core.git

#Reset homebrew-cask.git:
cd "$(brew --repo)"/Library/Taps/homebrew/homebrew-cask
git remote set-url origin https://github.com/Homebrew/homebrew-cask
#The Git address of Caskroom was migrated from https://github.com/caskroom/homebrew-cask to https://github.com/Homebrew/homebrew-cask on May 25, 2018. 

#Finally, comment out the homebrew robots in the /. Bash_profileand save them. Take bash as an example
cd ~
open .bash_profile

#Update. Bash? Profile
source .bash_profile

#Verification
brew update

Posted by mimilaw123 on Fri, 25 Oct 2019 11:24:27 -0700