命令行下使用代理(注意 shadowsocks需要通过额外的代理工具转换成 http代理,请移步),git_bash中也可以使用该命令工具。
创建代理脚本
vim /usr/local/bin/proxy
脚本内容如下
#!/bin/bash
http_proxy=http://127.0.0.1:8118 https_proxy=http://127.0.0.1:8118 $*
赋予可执行权限
chmod +x /usr/local/bin/proxy
运行时,在命令前面加 proxy,比如:proxy curl www.google.com
此外:git走的是ssh代理,需要使用git 官方提供的代理命令
#设置代理
git config --global http.proxy http://127.0.0.1:3129
git config --global https.proxy https://127.0.0.1:3129
#清空代理
git config --global --unset http.proxy
git config --global --unset https.proxy
#删除代理
npm config delete proxy