1.首先要能够科学上网,以我的ClashX Meta为例
2.如图,直接复制命令
3.你如果用的是bash,使用命令vi ~/.bash_profile,如果使用zsh,使用命令vi ~/.zshrc
然后将
alias export https_proxy=http://127.0.0.1:7890 http_proxy=http://127.0.0.1:7890 all_proxy=socks5://127.0.0.1:7890
alias proxyOff='unset http_proxy;unset https_proxy; unset all_proxy'
保存进去
4.使用source ~/.bash_profile或source ~/.zshrc使配置生效
5.使用命令curl ipinfo.io测试下代理是否开启成功
6.经过上面的操作开启终端的代理模式后,对于系统级命令已经完成了代理。但其他譬如 git 在使用时还需要环境变量支持,否则无法使用代理。
7.执行如下命令开启git代理
git config --``global` `http.proxy http:``//127.0.0.1:7890
git config --``global` `https.proxy https:``//127.0.0.1:7890
8.执行如下命令关闭git代理
git config -- global --unset http.proxy
git config -- global --unset https.proxy
搞定收工