当前位置:网站首页>Win10 Terminal + WSL 2 安装配置指南,精致开发体验
Win10 Terminal + WSL 2 安装配置指南,精致开发体验
2020-11-08 10:35:00 【osc_eijo4qvb】
自从 Windows Terminal 正式发布后就再没有用过 Windows 系统自带的终端了。主要是 Terminal 简洁且灵活,更重要的是支持特殊字体,通过一些简单的配置可以使得终端看起来更舒适养眼。
自从 Win 10 有了 Linux 子系统(WSL),早就把电脑上的 vmware 虚拟机软件卸载了。WSL 体验之好,谁用谁知道。
先给大家看看我个人的配置效果图:
安装 WSL 2
WSL,Windows Subsystem for Linux(适用于 Linux 的 Windows 子系统)的简写。它有两个版本,WSL 1 和 WSL 2。建议使用 WSL 2,它具有更好的整体性能。
安装 WSL 2,对不同架构的 CUP 有不同的 Win10 版本要求。为了简单起见,你只需确保你的 Win10 版本号为 2004(内部版本19041或更高)即可。PS:使用 win + r
输入 winver
可快速查看 Windows 版本。
如果你的 Win10 版本号低于 2004,可使用 Windows 10 易升工具手动升级。下载 Windows 10 易升工具:
https://www.microsoft.com/zh-cn/software-download/windows10
下载下来后双击运行,等待完成升级即可(升级过程比较漫长)。
安装 WSL 2 之前,必须启用“虚拟机平台”可选功能。使用管理员身份打开 PowerShell,执行以下命令:
dism.exe /online /enable-feature /featurename:VirtualMachinePlatform /all /norestart
接下来需要安装 Linux 分发版本。打开微软应用商店,搜索 Ubuntu,在列表中选择最新的长期支持版本 20.04 LTS 并安装。
使用任一终端,输入以下命令查看 WSL 版本,确保 WSL 的版本为 2.0:
$ wsl -l -v
NAME STATE VERSION
* Ubuntu-20.04 Stopped 2
如果你之前安装过 WSL,当前不是 WSL 2 版本,可以通过以下命令设置 WSL 的默认版本:
wsl --set-version Ubuntu-20.04 2
PS:从 WSL 1 更新到 WSL 2 可能需要几分钟才能完成,具体取决于目标分发版的大小。
安装 Terminal
打开微软应用商店,搜索“Terminal”,安装,打开后的界面是这样的:
默认打开的是 PownerShell 终端,我们可以设置为默认打开 Ubuntu 终端。点击标签右边的下拉三角,选择设置:
会打开一个 JSON 配置文件,在 profiles->list
中找到 Ubuntu 的 guid 并复制。
将它粘贴为文件开头的 defaultProfile
的值:
安装 oh-my-zsh
我们需要先安装一些额外的字体来支持 oh-my-zsh 显示特殊的符号。打开 PowerShell,依次执行如下命令 Powerline 字体集合:
git clone https://github.com/powerline/fonts.git
cd fonts
.\install.ps1
接着安装 zsh:
sudo apt update
sudo apt install git zsh -y
再安装 oh-my-zsh:
sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"
此步如果报如下错误:
curl: (7) Failed to connect to raw.githubusercontent.com port 443: Connection refused
解决办法有很多种,请自行解决。
安装完 oh-my-zsh 后,编辑 ~/.zshrc
文件,将主题设置为 agnoster
:
再次打开 Terminal 的 JSON 配置文件,在 schemes
中添加一个主题,主题名随意,这里为 wsl2
:
"schemes": [
{
"name" : "wsl2",
"background" : "#002B36",
"black" : "#002B36",
"blue" : "#268BD2",
"brightBlack" : "#657B83",
"brightBlue" : "#839496",
"brightCyan" : "#D33682",
"brightGreen" : "#B58900",
"brightPurple" : "#EEE8D5",
"brightRed" : "#CB4B16",
"brightWhite" : "#FDF6E3",
"brightYellow" : "#586E75",
"cyan" : "#2AA198",
"foreground" : "#93A1A1",
"green" : "#859900",
"purple" : "#6C71C4",
"red" : "#DC322F",
"white" : "#93A1A1",
"yellow" : "#B58900"
}
],
然后在该 JSON 文件中把 wsl 终端的主题设置为该 wsl2
主题,并把字体改为你喜欢的一个 Powerline 字体:
最后一步,再做一点点美化:把命令行的机器名称去掉,并调整用户名的背景色。编辑 agnoster 主题文件:
vi ~/.oh-my-zsh/themes/agnoster.zsh-theme
把 92 行修改为:
prompt_segment green black "%(!.%{%F{yellow}%}.)%n"
修改后如下:
关闭 Terminal 再重新打开,效果如下:
配置完成!
当然,你也可以去 Google 自己喜欢的主题,比如更为鲜亮的 Dracula 主题:
如若你在安装配置过程中遇到问题,请留言。
-
精致码农
带你洞悉编程与架构
↑长按图片识别二维码关注,不要错过网海相遇的缘分
版权声明
本文为[osc_eijo4qvb]所创,转载请带上原文链接,感谢
https://my.oschina.net/u/4323284/blog/4707985
边栏推荐
- Learning summary (about deep learning, vision and learning experience)
- 如何将 PyTorch Lightning 模型部署到生产中
- 为 Docsify 自动生成 RSS 订阅
- Windows10关机问题----只有“睡眠”、“更新并重启”、“更新并关机”,但是又不想更新,解决办法
- 个人目前技术栈
- M 端软件产品设计思虑札记 - 知乎
- Flink's sink: a preliminary study
- Analysis of ArrayList source code
- Improvement of rate limit for laravel8 update
- 【计算机网络】学习笔记,第三篇:数据链路层(谢希仁版)
猜你喜欢
Adobe Lightroom /Lr 2021软件安装包(附安装教程)
Japan PSE certification
How does spotify drive data-driven decision making?
Second assignment
蓝牙2.4G产品日本MIC认证的测试要求
技术人员该如何接手一个复杂的系统?
Oops, the system is under attack again
211考研失败后,熬夜了两个月拿下字节offer!【面经分享】
Shiyou's numerical analysis assignment
Flink's sink: a preliminary study
随机推荐
ASP.NET A complete solution based on exception handling in MVC
next.js实现服务端缓存
Px4 adds new applications
软件测试培训班出来好找工作么
维图PDMS切图软件
比Python快20%,就问你兴不兴奋?
Second assignment
If you don't understand the gap with others, you will never become an architect! What's the difference between a monthly salary of 15K and a monthly salary of 65K?
Solve the problem of rabbitmq message loss and repeated consumption
Learning summary (about deep learning, vision and learning experience)
[data structure Python description] use hash table to manually implement a dictionary class based on Python interpreter
架构师(2020年11月)
Fgagt: flow guided adaptive graph tracking
盘点那些你没想到的云计算应用场景(上)
2020-11-05
M-end software product design considerations - Zhihu
5g + Ar out of the circle, China Mobile Migu becomes the whole process strategic partner of the 33rd China Film Golden Rooster Award
[computer network] learning notes, Part 3: data link layer (Xie Xiren version)
We interviewed the product manager of SQL server of Alibaba cloud database, and he said that it is enough to understand these four problems
Is there a big difference between i5 1135g7 and i51035g1? Which is better?