临时设置
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