linux如何配置命令行全局代理?

为什么要配置命令行全局代理?

  • 我们在go语言开发的时候,安装vim插件的时候,有些资源不使用代理无法下载。这个时候配置一个全局代理,问题就轻松解决了。

配置

  • 在家目录中的.profile或.bash_profile文件中加入如下别名配置
  • 这里配置的是socks5代理
  • http代理配置只需要把配置socks改成http即可
alias proxy='export all_proxy=socks5://127.0.0.1:1080;export http_proxy=socks5://127.0.0.1:1080;export https_proxy=socks5://127.0.0.1:1080;export no_proxy=socks5://127.0.0.1:1080; export ALL_PROXY=socks5://127.0.0.1:1080;export HTTP_PROXY=socks5://127.0.0.1:1080;export HTTPS_PROXY=socks5://127.0.0.1:1080;export NO_PROXY=socks5://127.0.0.1:1080'
alias unproxy='unset all_proxy; unset http_proxy; unset https_proxy;unset no_proxy; unset ALL_PROXY; unset HTTP_PROXY; unset HTTPS_PROXY;unset NO_PROXY'

使用方法

  • 开启代理
proxy
  • 关闭代理
unproxy

测试

curl github.com