使用 curl,wget,brew等http应用程序会调用http_proxy和https_proxy这两环境变量进行代理,通过下面方式设置:
export http_proxy=http://127.0.0.1:8087
export https_proxy=$http_proxy
unset http_proxy https_proxy
可以在 ~/.zshrc 或者 ~/.bash_profile 中添加这样的alias:
alias goproxy='export http_proxy=http://127.0.0.1:8087 https_proxy=http://127.0.0.1:8087'
alias disproxy='unset http_proxy https_proxy'
这样下次就可以很方便地切换proxy了!
$ vi ~/.bash_profile
$ // 复制以下内容
alias goproxy='export http_proxy=http://127.0.0.1:1087 https_proxy=http://127.0.0.1:1087'
alias disproxy='unset http_proxy https_proxy'
// 命令生效
$ source ~/.bash_profile
env|grep -i proxy
unset http_proxy
unset https_proxy