常用代理设置

http://blog.peoplevip.cn/2021/3092852125.html#more

常用代理设置
以本机安装clash为例,代理地址 http://127.0.0.1:7890

git

设置代理

# http代理
git config --global http.proxy http://127.0.0.1:7890
git config --global https.proxy http://127.0.0.1:7890

# socks5代理(可选)
git config --global http.proxy "socks5://127.0.0.1:7890"
git config --global https.proxy "socks5://127.0.0.1:7890"

取消代理

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

bash

设置代理

# http代理
export http_proxy="http://127.0.0.1:7890"
export https_proxy="http://127.0.0.1:7890"

# socks5代理
export http_proxy="socks5://127.0.0.1:7890"
export https_proxy="socks5://127.0.0.1:7890"

取消代理

unset http_proxy
unset https_proxy

CMD

设置代理

# http代理
set http_proxy=http://127.0.0.1:7890
set https_proxy=http://127.0.0.1:7890

# socks5代理
set http_proxy=socks5://127.0.0.1:7890
set https_proxy=socks5://127.0.0.1:7890

取消代理

set http_proxy=
set https_proxy=

PowerShell

$Env:http_proxy="http://127.0.0.1:7890";
$Env:https_proxy="http://127.0.0.1:7890";

上方列出的关于终端的代理大多都是临时命令,重启终端就会失效,如果想要永久设置代理,可以使用使用自定义配置
在 PowerShell 窗口中运行如下指令:

if (!(Test-Path -Path $PROFILE )) { New-Item -Type File -Path $PROFILE -Force }
notepad $PROFILE

默认会使用记事本打开一个文件,在文件中加入上面设置代理的命令,保存关闭即可。

npm

设置代理

# http代理
npm config set proxy http://127.0.0.1:7890
npm config set https-proxy http://127.0.0.1:7890

取消代理

npm config delete proxy
npm config delete https-proxy

yarn

设置代理

# http代理
yarn config set proxy http://127.0.0.1:7890
yarn config set https-proxy http://127.0.0.1:7890

取消代理

yarn config delete proxy
yarn config delete https-proxy
posted @ 2021-03-03 08:43  tsvico  阅读(978)  评论(0编辑  收藏  举报