Skip to content

Cross the Wall

WSL

粘贴到 .bashrc 或者 .zshrc 或者别的什么配置文件里:

shell
host_ip=$(cat /etc/resolv.conf | grep "nameserver" | cut -f 2 -d " ")
export all_proxy=http://$host_ip:7890
export http_proxy=http://$host_ip:7890
export https_proxy=http://$host_ip:7890

PowerShell

PowerShell 的配置文件路径是变量 $PROFILE,复制到该文件:

powershell
$env:http_proxy="http://127.0.0.1:7890"
$env:https_proxy="http://127.0.0.1:7890"

没有该配置文件可以使用以下命令创建:

powershell
if (-not (Test-Path $profile)) {
  New-Item -ItemType File -Path (Split-Path $profile) -Force -Name (Split-Path $profile -Leaf)
}