Windows WSL 及 Windows Terminal 工具

WSL 的全称是 Windows Subsystem for Linux。这使得我们在 Windows 上直接使用 Linux 环境,比通过 VMware、VirtualBox 安装虚拟机更为便捷。至于性能,有看到网友进行了简单测试,与虚拟机里的系统不相上下。微软有在开发更高性能的 WSL2,不过还没正式放出。

基于 WSL 安装的 Linux 发行版都会有一个命令行终端,但比较难用。可以选择安装微软官方开发的”Windows Terminal“,目前还是预览版,但已经挺好用了。

如果发现系统不满足条件安装 WSL 和 Windows Terminal,需要升级到最新。

开启 WSL 相关可选组件

以管理员身份打开 PowerShell 并运行:

Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Windows-Subsystem-Linux

按输出提示,重启系统后生效。

在 WSL 上安装 Linux 发行版系统

打开系统自带的应用商店(Microsoft Store),搜索 Linux,即可看到多种 Linux 发行版。可以选择安装一个或多个。安装完后启动对应的发行版 Linux,会进行首次的初始化,需要输入用户名和密码设置。

然后按照个人需要修改软件源,安装 vim、g++、git 等工具软件。

安装及配置 Windows Terminal

同样是应用商店搜索安装。

新版本的 Windows Terminal 大为简化了配置。样式和快捷键需要自己再配置。以下是参考。

// https://github.com/microsoft/terminal/blob/master/doc/cascadia/SettingsSchema.md
// https://github.com/microsoft/terminal/blob/06bd7e22da183619b99b632e10e186d441b05e45/src/cascadia/TerminalApp/defaults.json

// To view the default settings, hold "alt" while clicking on the "Settings" button.
// For documentation on these settings, see: https://aka.ms/terminal-documentation

{
    "$schema": "https://aka.ms/terminal-profiles-schema",
    "defaultProfile": "{2c4de342-38b7-51cf-b940-2309a097f518}",

    "profiles":
    [
        {
            "guid": "{2c4de342-38b7-51cf-b940-2309a097f518}",
            "hidden": false,
            "name": "Ubuntu",
            "source": "Windows.Terminal.Wsl",
            "fontSize": 14,
            "fontFace": "Consolas",
            "cursorShape": "filledBox",
            "historySize": 10000,
            "colorScheme":"Dracula"
        },
        {
            "guid": "{2c4de342-38b7-51cf-b940-2309a097f519}",
            "commandline": "ssh.exe jack@192.168.1.60",
            "icon": "ms-appx:///ProfileIcons/{0caa0dad-35be-5f56-a8ff-afceeeaa6101}.png",
            "hidden": false,
            "name": "ssh1.60",
            "fontSize": 14,
            "fontFace": "Consolas",
            "cursorShape": "filledBox",
            "historySize": 10000,
            "colorScheme":"Dracula"
        },
        {
            // Make changes here to the powershell.exe profile
            "guid": "{61c54bbd-c2c6-5271-96e7-009a87ff44bf}",
            "name": "Windows PowerShell",
            "commandline": "powershell.exe",
            "hidden": false
        },
        {
            // Make changes here to the cmd.exe profile
            "guid": "{0caa0dad-35be-5f56-a8ff-afceeeaa6101}",
            "name": "cmd",
            "commandline": "cmd.exe",
            "hidden": false
        },
        {
            "guid": "{b453ae62-4e3d-5e58-b989-0a998ec441b8}",
            "hidden": false,
            "name": "Azure Cloud Shell",
            "source": "Windows.Terminal.Azure"
        }
    ],

    // Add custom color schemes to this array
    "schemes": [
        {
            "background":  "#282A36",
            "black":  "#21222C",
            "blue":  "#F1FA8C",
            "brightBlack":  "#6272A4",
            "brightBlue":  "#D6ACFF",
            "brightCyan":  "#A4FFFF",
            "brightGreen":  "#69FF94",
            "brightPurple":  "#FF92DF",
            "brightRed":  "#FF6E6E",
            "brightWhite":  "#FFFFFF",
            "brightYellow":  "#FFFFA5",
            "cyan":  "#8BE9FD",
            "foreground":  "#F8F8F2",
            "green":  "#50FA7B",
            "name":  "Dracula",
            "purple":  "#BD93F9",
            "red":  "#FF5555",
            "white":  "#F8F8F2",
            "yellow":  "#F1FA8C"
        }
    ],

    // Add any keybinding overrides to this array.
    // To unbind a default keybinding, set the command to "unbound"
    "keybindings": [
        { "command": "newTabProfile0", "keys": ["ctrl+shift+1"] },
        { "command": "newTabProfile1", "keys": ["ctrl+shift+2"] },
        { "command": "newTabProfile2", "keys": ["ctrl+shift+3"] },
        { "command": "newTabProfile3", "keys": ["ctrl+shift+4"] },
        { "command": "newTabProfile4", "keys": ["ctrl+shift+5"] },
        { "command": "newTabProfile5", "keys": ["ctrl+shift+6"] },
        { "command": "newTabProfile6", "keys": ["ctrl+shift+7"] },
        { "command": "newTabProfile7", "keys": ["ctrl+shift+8"] },
        { "command": "newTabProfile8", "keys": ["ctrl+shift+9"] },
        { "command": "nextTab", "keys": ["ctrl+tab"] },
        { "command": "paste", "keys": ["ctrl+shift+v"] },
        { "command": "prevTab", "keys": ["ctrl+shift+tab"] },
        { "command": "scrollDown", "keys": ["ctrl+shift+down"] },
        { "command": "scrollDownPage", "keys": ["ctrl+shift+pgdn"] },
        { "command": "scrollUp", "keys": ["ctrl+shift+up"] },
        { "command": "scrollUpPage", "keys": ["ctrl+shift+pgup"] },
        { "command": "switchToTab0", "keys": ["alt+1"] },
        { "command": "switchToTab1", "keys": ["alt+2"] },
        { "command": "switchToTab2", "keys": ["alt+3"] },
        { "command": "switchToTab3", "keys": ["alt+4"] },
        { "command": "switchToTab4", "keys": ["alt+5"] },
        { "command": "switchToTab5", "keys": ["alt+6"] },
        { "command": "switchToTab6", "keys": ["alt+7"] },
        { "command": "switchToTab7", "keys": ["alt+8"] },
        { "command": "switchToTab8", "keys": ["alt+9"] }
    ]
}

Windows Terminal 配置 SSH

配置中有一个叫 ssh1.60 的 profile,是用来登陆远程主机的。这也是一个便捷的用法。配合 ssh 的公钥登陆,就更方便了。

  • PoweShell 下执行 ssh-keygen.exe 生成公钥私钥文件。

  • C:\Users\Username\.ssh\id_rsa.pub 获取公钥,配置到远程主机。

win10 WSL2 引起的 VirtualBox 启动问题》https://blog.csdn.net/engrossment/article/details/99431539

2019年10月18日

  • 1
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

Jackindata

多谢认可!

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值