Skip to content
This repository has been archived by the owner on Jul 14, 2023. It is now read-only.

Latest commit

 

History

History
71 lines (50 loc) · 1.98 KB

README.md

File metadata and controls

71 lines (50 loc) · 1.98 KB

Windows 环境配置

WSL 简介

https://docs.microsoft.com/zh-cn/windows/wsl/

安装 WSL

在 Windows(10 及以上)的操作系统中安装WSL(建议使用 WSL2 ,本文档内容也以 WSL2 为基础)

推荐使用 Ubuntu 20.04 LTS,Microstoft Store 安装链接

使用WSL后系统环境将变得简单,其他相关的环境配置可以参考本导引Unix内容

WSL 不继承 Windows 环境变量

避免出现一些不可控情况

sudo nano /etc/wsl.conf #编辑文件`/etc/wsl.conf`

加入以下内容

[interop]
appendWindowsPath = false

在PowerShell中重启 WSL

WSL --shutdown

WSL 内部 Proxy 环境脚本

将下面函数加入到~/.profile中,记得编辑端口

export hostip=$(cat /etc/resolv.conf |grep -oP '(?<=nameserver\ ).*') #获得网关地址
export proxyPort=7890 #端口
alias proxy='
    export https_proxy="http://${hostip}:${proxyPort}";
    export http_proxy="http://${hostip}:${proxyPort}";
    export all_proxy="http://${hostip}:${proxyPort}";
    echo -e "Acquire::http::Proxy \"http://${hostip}:${proxyPort}\";" | sudo tee -a /etc/apt/apt.conf.d/proxy.conf > /dev/null;
    echo -e "Acquire::https::Proxy \"http://${hostip}:${proxyPort}\";" | sudo tee -a /etc/apt/apt.conf.d/proxy.conf > /dev/null;
'
alias unproxy='
    unset https_proxy;
    unset http_proxy;
    unset all_proxy;
    sudo sed -i -e "/Acquire::http::Proxy/d" /etc/apt/apt.conf.d/proxy.conf;
    sudo sed -i -e "/Acquire::https::Proxy/d" /etc/apt/apt.conf.d/proxy.conf;
'

测试可用性

source ~/.profile #加载环境
proxy #执行函数 代理生效
curl https://www.google.com #请求Google 网址

Visual Studio Code

https://code.visualstudio.com