zsh设置代理


临时设置

export http_proxy=http://127.0.0.1:8087
export https_proxy=$http_proxy
export socks5_proxy="socks5://127.0.0.1:60879"

永久设置

$ vim ~/.zshrc
# proxy
proxy () {
  export http_proxy="http://127.0.0.1:60879"
  export https_proxy=$http_proxy
  export socks5_proxy="socks5://127.0.0.1:60879"
  echo "HTTP Proxy on"
}

# noproxy
noproxy () {
  unset http_proxy
  unset https_proxy
  echo "HTTP Proxy off"
}

$ source ~/.zshrc

使用

➜  ~ proxy
HTTP Proxy on
➜  ~ noproxy
HTTP Proxy off

测试

curl ip.sb

如果用 bash,可以直接上面命令的 ~/.zshrc 换成 ./.bash_profile


这篇文章对你有帮助吗?作为一名程序工程师,在评论区留下你的困惑或你的见解,大家一起来交流吧!
微信公众号: Mysticbinary
Github:https://github.com/Mysticbinary
本文版权归作者所有,欢迎转载,但未经作者同意请保留此段声明,请在文章页面明显位置给出原文链接
声明:本文章仅限于讨论网络安全技术,请勿用作任何非法用途,否则后果自负,本人和博客园不承担任何责任!
原文地址:https://www.cnblogs.com/mysticbinary/p/14522644.html