欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

Windows10 和 WSL 环境下安装 Windows Terminal 和 VS Code

程序员文章站 2022-06-26 13:22:21
...

1.Windows Terminal

在 Microsoft Build 2019 大会上,微软发布了新一代 Windows 终端工具:Windows Terminal。其令人惊艳的 Fluent UI 设计、亚克力半透明材质的背景和对 UTF-8、Emoji 等特殊字符的支持让大家赞叹不已。

目前,Windows Terminal 已经可以直接从 Microsoft Store 中直接下载。

Windows10 和 WSL 环境下安装 Windows Terminal 和 VS Code

安装成功之后,启动 Windows Terminal 默认打开 PowerShell。

Windows10 和 WSL 环境下安装 Windows Terminal 和 VS Code

Windows Terminal 可以直接识别出来我们本机上面安装的全部 WSL 环境、PowerShell 环境和 Command Prompt 环境。点击下拉菜单,我们就可以看到 Windows Terminal 唤起的环境。

Windows10 和 WSL 环境下安装 Windows Terminal 和 VS Code

2.Visual Studio Code

进入 VS Code 官网 下载,傻瓜安装即可。

下面着重介绍如何在 WSL 环境下 Ubantu 20.04 LTS 系统中使用 VS Code。

首先在 VS Code 中安装 WSL 的插件:

Windows10 和 WSL 环境下安装 Windows Terminal 和 VS Code

在 Windows Terminal 中打开 Ubantu 20.04 LTS,默认目录如下:

Windows10 和 WSL 环境下安装 Windows Terminal 和 VS Code

实际上微软为我们提供了一个默认的变量可以直接指向 WSL 的目录,即 wsl$。你可以在运行(win+R)或资源管理器的路径里直接输入 \\wsl$ 进入 Ubuntu 的目录。

Windows10 和 WSL 环境下安装 Windows Terminal 和 VS Code
Windows10 和 WSL 环境下安装 Windows Terminal 和 VS Code

知道 WSL 的网络路径后你可以直接将它添加到资源管理器的网络位置里:

Windows10 和 WSL 环境下安装 Windows Terminal 和 VS Code

然后,这里我进入 home 目录,创建了一个 test_code 文件夹,进入 test_code 文件夹,执行 code . 命令,等待安装 VS Code Server。

Windows10 和 WSL 环境下安装 Windows Terminal 和 VS Code

VS Code Server 安装完成后,会自动打开弹出 VS Code,并且文件目录恰好就是 test_code

Windows10 和 WSL 环境下安装 Windows Terminal 和 VS Code

在 VS Code 中,test_code 下新建一个 hello.py,并输入以下代码:

print('hello world!')
Windows10 和 WSL 环境下安装 Windows Terminal 和 VS Code

同时,在 Windows Terminal 中可以看到 test_code 目录下多了一个 hello.py,并执行命令 python3 hello.py,在 Windows Terminal 中可以看到打印出了一行 hello world!

Windows10 和 WSL 环境下安装 Windows Terminal 和 VS Code

至此,WSL 下 Windows Terminal 和 VS Code 两大利器安装完毕。

3.参考资料

  1. Dev on Windows with WSL:可能是市面上最详尽的中文 WSL 开发环境配置指南
  2. windows10 ubuntu子系统 WSL文件位置
  3. B站UP主"麦兜搞IT":Windows10开发环境搭建(2) | Terminal和VS Code
相关标签: CSAPP