有时候需要在命令行中或者全局使用代理工具,假定代理工具的命令行指令如下:
export https_proxy=http://127.0.0.1:7890 http_proxy=http://127.0.0.1:7890 all_proxy=socks5://127.0.0.1:7891
那么我们可以在~/.zshrc的文件后面添加两个命令:
# 启动代理
proxy () {
export https_proxy=http://127.0.0.1:7890 http_proxy=http://127.0.0.1:7890 all_proxy=socks5://127.0.0.1:7891
echo "HTTP Proxy on"
}
# 关闭代理
noproxy () {
unset http_proxy
unset https_proxy
unset all_proxy
echo "HTTP Proxy off"
}
配置结束后在命令行中执行:
source ~/.zshrc
# 打开代理
proxy
# 关闭代理
noproxy
参考
https://fangzf.me/2017/05/08/%E8%AE%A9-Zsh-%E7%BB%88%E7%AB%AF%E8%B5%B0%E4%BB%A3%E7%90%86/
网友评论