在终端下需要走代理的时候,就执行p1,取消就执行p0,当然具体的指令别名,你可以自己定义。
设置开启代理的别名:
1 | alias p1='export http_proxy=http://127.0.0.1:2334;export https_proxy=http://127.0.0.1:2334;export ALL_PROXY=socks5://127.0.0.1:2334' |
设置关闭代理的别名:
1 | alias p0='unset http_proxy;unset https_proxy;unset ALL_PROXY' |
把两段 alias 指令,保存到终端的用户配置环境文件当中,比如 .profile 之类,然后使用 source ~/.profile 立即激活即可。这样每次启动终端都能使用了。