Windows10 和 WSL 环境下安装 Windows Terminal 和 VS Code
1.Windows Terminal
在 Microsoft Build 2019 大会上,微软发布了新一代 Windows 终端工具:Windows Terminal。其令人惊艳的 Fluent UI 设计、亚克力半透明材质的背景和对 UTF-8、Emoji 等特殊字符的支持让大家赞叹不已。
目前,Windows Terminal 已经可以直接从 Microsoft Store 中直接下载。
安装成功之后,启动 Windows Terminal 默认打开 PowerShell。
Windows Terminal 可以直接识别出来我们本机上面安装的全部 WSL 环境、PowerShell 环境和 Command Prompt 环境。点击下拉菜单,我们就可以看到 Windows Terminal 唤起的环境。
2.Visual Studio Code
进入 VS Code 官网 下载,傻瓜安装即可。
下面着重介绍如何在 WSL 环境下 Ubantu 20.04 LTS 系统中使用 VS Code。
首先在 VS Code 中安装 WSL 的插件:
在 Windows Terminal 中打开 Ubantu 20.04 LTS,默认目录如下:
实际上微软为我们提供了一个默认的变量可以直接指向 WSL 的目录,即 wsl$
。你可以在运行(win+R)或资源管理器的路径里直接输入 \\wsl$
进入 Ubuntu 的目录。
知道 WSL 的网络路径后你可以直接将它添加到资源管理器的网络位置里:
然后,这里我进入 home
目录,创建了一个 test_code
文件夹,进入 test_code
文件夹,执行 code .
命令,等待安装 VS Code Server。
VS Code Server 安装完成后,会自动打开弹出 VS Code,并且文件目录恰好就是 test_code
。
在 VS Code 中,test_code
下新建一个 hello.py
,并输入以下代码:
print('hello world!')
同时,在 Windows Terminal 中可以看到 test_code
目录下多了一个 hello.py
,并执行命令 python3 hello.py
,在 Windows Terminal 中可以看到打印出了一行 hello world!
。
至此,WSL 下 Windows Terminal 和 VS Code 两大利器安装完毕。
3.参考资料
下一篇: $CODE$