Linux 让终端走 proxy 的几种方法
前期准备
假设已搭建本地服务
socks5://127.0.0.1:1080
http://127.0.0.1:1081
方式一
在终端运行 export http_proxy=http://proxyAddress:port
# http 代理
export http_proxy=http://127.0.0.1:1081
# https 代理
export https_proxy=http://127.0.0.1:1081
方式二
在 ~/.bashrc
、~/.zshrc
中添加内容
export http_proxy="http://127.0.0.1:1081"
export https_proxy="http://127.0.0.1:1081"
或直接走 socks5
export http_proxy="socks5://127.0.0.1:1080"
export https_proxy="socks5://127.0.0.1:1080"
或全流量走 socks5
export ALL_PROXY=socks5://127.0.0.1:1080
可通过设置别名方式,方便调用
alias setproxy="export ALL_PROXY=socks5://127.0.0.1:1080" alias unsetproxy="unset ALL_PROXY"
Git 中使用加速
git config --global http.proxy 'socks5://127.0.0.1:1080'
git config --global https.proxy 'socks5://127.0.0.1:1080'
内容节选自:https://zhuanlan.zhihu.com/p/46973701