设置终端wget curl git npm等代理

设置终端代理

临时终端代理设置

1
2
export http_proxy=http://127.0.0.1:10808
export https_proxy=http://127.0.0.1:10808

设置http代理,如果要设置socks5代理,相对应把协议头改成socks5

1
2
echo $http_proxy
echo $https_proxy

显示环境变量,如果输出当前代理则设置成功,注意协议头不要写错

当前环境变量只对当前终端配置生效,重新打开后需要重新设置

1
2
3
# 强制所有都走代理
export ALL_PROXY=socks5://127.0.0.1:1080

设置永久代理

编辑终端配置文件vim ~/.zshrc 添加

1
2
export http_proxy=http://127.0.0.1:10808
export https_proxy=http://127.0.0.1:10808

相对应socks5代理改一下协议头

git代理设置

设置http代理,socks5代理更换相应协议头

1
2
git config --gloable http.proxy=http://127.0.0.1:10808
git config --gloable https.proxy=http://127.0.0.1:10808

取消代理

1
2
git config --global --unset http.proxy
git config --global --unset https.proxy

git代理配置文件可在.gitconfig中查看,如果显示相对应代理参数,则设置成功

npm代理设置

设置http代理

1
npm config set proxy=http://127.0.0.1:10808

可通过npm config list ls -l 查看全部代理设置