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

相关文章:

  • 2021-06-04
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2021-12-15
  • 2022-02-04
  • 2022-12-23
  • 2022-01-29
  • 2021-12-09
  • 2021-12-06
相关资源
相似解决方案