常用代理设置

tsvico Lv5

常用代理设置

以本机安装 clash 为例,混合代理地址 127.0.0.1:7890

git

  • 设置代理

    1
    2
    3
    # http代理
    git config --global http.proxy http://127.0.0.1:7890
    git config --global https.proxy http://127.0.0.1:7890
    1
    2
    3
    # socks5代理(可选)
    git config --global http.proxy "socks5://127.0.0.1:7890"
    git config --global https.proxy "socks5://127.0.0.1:7890"
  • 取消代理

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

bash

  • 设置代理

    1
    2
    3
    # http代理
    export http_proxy="http://127.0.0.1:7890"
    export https_proxy="http://127.0.0.1:7890"
    1
    2
    3
    # socks5代理
    export http_proxy="socks5://127.0.0.1:7890"
    export https_proxy="socks5://127.0.0.1:7890"
  • 取消代理

    1
    2
    unset http_proxy
    unset https_proxy
  • 永久生效

    修改 ~/.bashrc 或者 ~/.zshrc 文件

CMD

  • 设置代理

    1
    2
    3
    # http代理
    set http_proxy=http://127.0.0.1:7890
    set https_proxy=http://127.0.0.1:7890
    1
    2
    3
    # socks5代理
    set http_proxy=socks5://127.0.0.1:7890
    set https_proxy=socks5://127.0.0.1:7890
  • 取消代理

    1
    2
    set http_proxy=
    set https_proxy=

PowerShell

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

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

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

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

npm

  • 设置代理

    1
    2
    3
    # http代理
    npm config set proxy http://127.0.0.1:7890
    npm config set https-proxy http://127.0.0.1:7890
  • 取消代理

    1
    2
    npm config delete proxy
    npm config delete https-proxy

yarn

  • 设置代理

    1
    2
    3
    # http代理
    yarn config set proxy http://127.0.0.1:7890
    yarn config set https-proxy http://127.0.0.1:7890
  • 取消代理

    1
    2
    yarn config delete proxy
    yarn config delete https-proxy
  • 标题: 常用代理设置
  • 作者: tsvico
  • 创建于 : 2021-02-28 14:55:30
  • 更新于 : 2022-05-22 16:05:38
  • 链接: https://blog.tbox.fun/2021/3092852125.html
  • 版权声明: 本文章采用 CC BY-NC-SA 4.0 进行许可。
评论
目录
常用代理设置