大家都在点赞 Windows Terminal,我决定给你泼一盆冷水

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了大家都在点赞 Windows Terminal,我决定给你泼一盆冷水相关的知识,希望对你有一定的参考价值。

参考技术A Windows Terminal 发布以后,立刻引爆了整个技术圈,各种社交媒体上纷纷传播着它的消息,它开源的 GitHub 仓库的星标数一路飙升,迅速成为当日 GitHub 趋势榜的首名,甚至连它 issue 区都挤满了人——以至于项目运营团队紧急出场管理。不过,在我观看了相关的资料和视频以后,感觉并没有那么令人兴奋。

在我看到一时间出现的很多文章,都视 Windows Terminal 为 Windows 下命令行体验的救世主之后,我觉得,是时候泼一盆冷水降降温了。

在泼冷水之前,我想先来介绍一下 Windows Terminal 是什么,以方便你理解我的观点:Windows Terminal 是一个套在 Windows 操作系统原本的 CMD、Powershell、Windows Subsystem for Linux(WSL)之上的一个界面更加漂亮、功能更加强大的终端工具。严格来说,它是套在 CMD 、Powershell 之上的一个终端。

但是,它也只是一个终端而已,而不是一个更加好用的 Shell。

作为一个终端,Windows Terminal 无疑是合格的,它提供了非常强大的功能,来自微软的强大工程能力也让它能够吸引更多的眼球。

但是,如果仅仅是一个终端,其实开源社区早已有更多的解决方案,比如 cmder 、 ConEmu 、 Hyper 等等,这些 Terminal 也足够好看和好用。

这种第三方就可以做好的事情,微软官方的进入不过是在现有的命令行生态下提供更多的一种选择,而不是真正的问题解决方案。

那么我们是对什么不满意呢?Windows 用户所吐槽的命令行不好用不在于其表面,而在于其没有一个足够好用的 Shell。 Windows 下的两个命令行界面都各有自己的问题,CMD 因为时间久远,很多功能不齐全。而 Power Shell 虽然功能强大,但不合理的命令语法,大量冗长的、驼峰式命名的命令和参数使得用户的命令操作极为不便,体验极差。如果没有一个足够好用的 Shell ,无论换了多少外面的终端,无非是披了一个闪闪发光的、半透明的漂亮外衣罢了。

对于开发者们来说,真正希望 Windows 做的,不是一个更漂亮的终端。漂亮的终端只能让他们一时新鲜,但是如果希望开发者们真正感觉到 Windows 命令行好用,就需要提供一个更加强大的 Shell,帮助开发者能够用上 Unix 式的命令行工具。

在 Microsoft Build 2019 大会上,除了 Windows Terminal 以外,还发布了 Windows Subsystem for Linux 2(WSL2)。新一代的 WSL 相比于上一代,提供了完整的 Linux 内核,将会提供更好的系统支持。看起来,Windows Terminal 和 WSL 的结合,已经非常完美了,但作为一个 Shell 来用的话,又显的过于笨重。

WSL 2 所提供的,不过是一个更加简单、更加易用的 Windows 下的虚拟机,你不再需要安装 Virtual Box、VMWare 而已,一个 Windows Subsystem for Linux 就可以满足开发者的大部分需求。

但是,这并不能解决问题,这治标不治本的选择。WSL 无论做的再怎么好,无法摆脱它只是一个运行于 Windows 系统中附属的子系统。无论 WSL 做的再好,本质上并没有比虚拟机做的更多。

作为 Windows 系统的开发者,微软真正的价值显然不是做一个终端那么简单。作为生态的打造者,微软真正可以做好的是,打造一个能够在体验和生态上与 Unix Shell 一致的 Shell,或者是干脆提供 Bash、Zsh 等常用 Shell 的原生支持(WSL 虽然支持 Bash、Zsh等,但依然是需要先进入 WSL 才能使用,但你可以畅想一下,如果 CMD 变成了 Bash,会是什么样的呢?)。这些事情是第三方开发者所无法做的更好的,只有生态的构建者在一开始就将一个体验良好的 Shell 放置在系统的核心,无需开发者自行安装、配置,才能够让开发者真正拥有一个好的命令行体验。如果微软能提供一个足够好用的 Shell,我相信类似于 Windows Terminal 这样的应用,会如雨后春笋一般,从开源社区中源源不断的冒出来。

对于广大使用 Windows 开发的用户来说,一个闪闪发亮的、现代化的、功能强大的终端固然很好,但好的终端只不过是锦上添花之举,而一个强大好用的 Shell 才是真正能够雪中送炭的东西,只有一个足够好用的 Shell,才能成为 Windows 命令行世界的救世主。而这,才是真正值得微软花费大量的时间、精力去做的。

Windows Terminal

先记录后面再补充

在当前目录地址(使用场景都是 Windows Terminal 配置)打开 Windows Terminal:

PS> $ start-process -WorkingDirectory ($PWD.Path) "wt.exe"
# 或者
PS> $ start-process "wt.exe" -ArgumentList "-d","."
# 注意:
#   例如, 使用上面命令打开了 "E:/demo/test" 目录之后打开的窗口哪怕使用 \'cd\' 切换到 "E:/demo" 这个目录
#   使用 快捷键 \'shift + ctl + 1\' 打开都会实在 "E:/demo/test" 这个目录下而不是 "E:/demo" 这个目录
# 这点没有像 Linux 或者 MacOS 系统下的终端打开新的 tab 那样。
# 需要做到上面的功能,还要将 快捷键对应的 \'tab\' 创建时候的 \'start directory\' 设置为 "."
#   \'-ArgumentList\' 只对 "-d","." 有反应,如果是写成 "-d","$env:projectDirectory" 是不会有作用的

先记录后整理
快捷键说明
/// https://docs.microsoft.com/en-us/windows/terminal/customize-settings/actions
        /// https://docs.microsoft.com/en-us/windows/terminal/customize-settings/actions#accepted-modifiers-and-keys
        /**
         * PS:
         *      keys: \'+\' 和按键值之间不能为空
         *      多用 alt+ 或者 shift+alt+
         * 虽然允许 `win` 键,但是 `win` 配合 其他键 + 数字,会有其他效果,后面研究会出一篇文章 
         */
        /// 快捷键清屏
        { "command": { "action": "sendInput", "input": "clear\\r" }, "keys": "alt+k" },
        /// 打开 重命名 的 text box
        { "command": { "action": "openTabRenamer" }, "keys": "shift+alt+r" },
        { "command": { "action": "setTabColor", "color": "#FAFF59" }, "keys": "shift+alt+1" },
        /**
         * 打开 colorpicker, 下面的 alt+c+p 其实有效的是 alt+p c按键的值会input 到 screen 中
         */
        // { "command": { "action": "openTabColorPicker" }, "keys": "alt+c+p" }
        // 
        { "command": { "action": "openTabColorPicker" }, "keys": "shift+alt+p" }


我的 Windows Terminal 配置:

{
    "$schema": "https://aka.ms/terminal-profiles-schema",
    // Add custom actions and keybindings to this array.
    // To unbind a key combination from your defaults.json, set the command to "unbound".
    // To learn more about actions and keybindings, visit https://aka.ms/terminal-keybindings
    "actions": 
    [
        // Copy and paste are bound to Ctrl+Shift+C and Ctrl+Shift+V in your defaults.json.
        // These two lines additionally bind them to Ctrl+C and Ctrl+V.
        // To learn more about selection, visit https://aka.ms/terminal-selection
        {
            "command": 
            {
                "action": "copy",
                "singleLine": false
            },
            "keys": "ctrl+c"
        },
        {
            "command": "paste",
            "keys": "ctrl+v"
        },
        // Press Ctrl+Shift+F to open the search box
        {
            "command": "find",
            "keys": "ctrl+shift+f"
        },
        // Press Alt+Shift+D to open a new pane.
        // - "split": "auto" makes this pane open in the direction that provides the most surface area.
        // - "splitMode": "duplicate" makes the new pane use the focused pane\'s profile.
        // To learn more about panes, visit https://aka.ms/terminal-panes
        {
            "command": 
            {
                "action": "splitPane",
                "split": "auto",
                "splitMode": "duplicate"
            },
            "keys": "alt+shift+d"
        },
        /// https://docs.microsoft.com/en-us/windows/terminal/customize-settings/actions
        /// https://docs.microsoft.com/en-us/windows/terminal/customize-settings/actions#accepted-modifiers-and-keys
        /**
         * PS:
         *      keys: \'+\' 和按键值之间不能为空
         *      多用 alt+ 或者 shift+alt+
         * 虽然允许 `win` 键,但是 `win` 配合 其他键 + 数字,会有其他效果,后面研究会出一篇文章 
         */
        /// 快捷键清屏
        { "command": { "action": "sendInput", "input": "clear\\r" }, "keys": "alt+k" },
        /// 打开 重命名 的 text box
        { "command": { "action": "openTabRenamer" }, "keys": "shift+alt+r" },
        { "command": { "action": "setTabColor", "color": "#FAFF59" }, "keys": "shift+alt+1" },
        /**
         * 打开 colorpicker, 下面的 alt+c+p 其实有效的是 alt+p c按键的值会input 到 screen 中
         */
        // { "command": { "action": "openTabColorPicker" }, "keys": "alt+c+p" }
        // 
        { "command": { "action": "openTabColorPicker" }, "keys": "shift+alt+p" }
    ],
    "copyFormatting": "none",
    "copyOnSelect": false,
    "defaultProfile": "{574e775e-4f2a-5b96-ac1e-a2962a402336}",
    "profiles": 
    {
        "defaults": 
        {
            "cursorColor": "#FFFFFF",
            "cursorShape": "bar",
            "fontFace": "MesloLGS NF",
            "fontSize": 14,
            "startingDirectory": "."
        },
        "list": 
        [
            {
                "commandline": "C:\\\\Program Files\\\\PowerShell\\\\7\\\\pwsh.exe",
                "fontFace": "MesloLGM NF",
                "fontSize": 10,
                "guid": "{574e775e-4f2a-5b96-ac1e-a2962a402336}",
                "hidden": false,
                "name": "PowerShell",
                "source": "Windows.Terminal.PowershellCore",
                "startingDirectory": "."
            },
            {
                "fontSize": 11,
                "guid": "{58ad8b0c-3ef8-5f4d-bc6f-13e4c00f2530}",
                "hidden": false,
                "name": "Debian",
                "source": "Windows.Terminal.Wsl"
            },
            {
                "commandline": "powershell.exe",
                "fontFace": "DroidSansMono NF",
                "fontSize": 11,
                "guid": "{61c54bbd-c2c6-5271-96e7-009a87ff44bf}",
                "hidden": false,
                "name": "Windows PowerShell"
            },
            {
                "commandline": "powershell.exe -command Start-Process -Verb RunAs \\"shell:appsFolder\\\\Microsoft.WindowsTerminal_8wekyb3d8bbwe!App\\"",
                "hidden": false,
                "icon": "ms-appx:///Images/Square44x44Logo.targetsize-32.png",
                "name": "Windows Terminal (elevated)"
            },
            {
                "commandline": "powershell.exe -command Start-Process -Verb RunAs \\"wt.exe\\"",
                "hidden": false,
                "icon": "ms-appx:///Images/Square44x44Logo.targetsize-32.png",
                "name": "Windows Terminal (elevated2)"
            },
            {
                "commandline": "powershell.exe -command Start-Process -Verb RunAs \\"pwsh.exe\\"",
                "icon": "ms-appx:///ProfileIcons/pwsh.png",
                "name": "pwsh admin"
            },
            {
                "commandline": "cmd.exe",
                "fontSize": 10,
                "guid": "{0caa0dad-35be-5f56-a8ff-afceeeaa6101}",
                "hidden": false,
                "name": "\\u547d\\u4ee4\\u63d0\\u793a\\u7b26",
                "startingDirectory": "%USERPROFILE%"
            },
            {
                "guid": "{b453ae62-4e3d-5e58-b989-0a998ec441b8}",
                "hidden": false,
                "name": "Azure Cloud Shell",
                "source": "Windows.Terminal.Azure"
            }
        ]
    },
    "schemes": 
    [
        {
            "background": "#0C0C0C",
            "black": "#0C0C0C",
            "blue": "#0037DA",
            "brightBlack": "#767676",
            "brightBlue": "#3B78FF",
            "brightCyan": "#61D6D6",
            "brightGreen": "#16C60C",
            "brightPurple": "#B4009E",
            "brightRed": "#E74856",
            "brightWhite": "#F2F2F2",
            "brightYellow": "#F9F1A5",
            "cursorColor": "#FFFFFF",
            "cyan": "#3A96DD",
            "foreground": "#CCCCCC",
            "green": "#13A10E",
            "name": "Campbell",
            "purple": "#881798",
            "red": "#C50F1F",
            "selectionBackground": "#FFFFFF",
            "white": "#CCCCCC",
            "yellow": "#C19C00"
        },
        {
            "background": "#012456",
            "black": "#0C0C0C",
            "blue": "#0037DA",
            "brightBlack": "#767676",
            "brightBlue": "#3B78FF",
            "brightCyan": "#61D6D6",
            "brightGreen": "#16C60C",
            "brightPurple": "#B4009E",
            "brightRed": "#E74856",
            "brightWhite": "#F2F2F2",
            "brightYellow": "#F9F1A5",
            "cursorColor": "#FFFFFF",
            "cyan": "#3A96DD",
            "foreground": "#CCCCCC",
            "green": "#13A10E",
            "name": "Campbell Powershell",
            "purple": "#881798",
            "red": "#C50F1F",
            "selectionBackground": "#FFFFFF",
            "white": "#CCCCCC",
            "yellow": "#C19C00"
        },
        {
            "background": "#282C34",
            "black": "#282C34",
            "blue": "#61AFEF",
            "brightBlack": "#5A6374",
            "brightBlue": "#61AFEF",
            "brightCyan": "#56B6C2",
            "brightGreen": "#98C379",
            "brightPurple": "#C678DD",
            "brightRed": "#E06C75",
            "brightWhite": "#DCDFE4",
            "brightYellow": "#E5C07B",
            "cursorColor": "#FFFFFF",
            "cyan": "#56B6C2",
            "foreground": "#DCDFE4",
            "green": "#98C379",
            "name": "One Half Dark",
            "purple": "#C678DD",
            "red": "#E06C75",
            "selectionBackground": "#FFFFFF",
            "white": "#DCDFE4",
            "yellow": "#E5C07B"
        },
        {
            "background": "#FAFAFA",
            "black": "#383A42",
            "blue": "#0184BC",
            "brightBlack": "#4F525D",
            "brightBlue": "#61AFEF",
            "brightCyan": "#56B5C1",
            "brightGreen": "#98C379",
            "brightPurple": "#C577DD",
            "brightRed": "#DF6C75",
            "brightWhite": "#FFFFFF",
            "brightYellow": "#E4C07A",
            "cursorColor": "#4F525D",
            "cyan": "#0997B3",
            "foreground": "#383A42",
            "green": "#50A14F",
            "name": "One Half Light",
            "purple": "#A626A4",
            "red": "#E45649",
            "selectionBackground": "#FFFFFF",
            "white": "#FAFAFA",
            "yellow": "#C18301"
        },
        {
            "background": "#002B36",
            "black": "#002B36",
            "blue": "#268BD2",
            "brightBlack": "#073642",
            "brightBlue": "#839496",
            "brightCyan": "#93A1A1",
            "brightGreen": "#586E75",
            "brightPurple": "#6C71C4",
            "brightRed": "#CB4B16",
            "brightWhite": "#FDF6E3",
            "brightYellow": "#657B83",
            "cursorColor": "#FFFFFF",
            "cyan": "#2AA198",
            "foreground": "#839496",
            "green": "#859900",
            "name": "Solarized Dark",
            "purple": "#D33682",
            "red": "#DC322F",
            "selectionBackground": "#FFFFFF",
            "white": "#EEE8D5",
            "yellow": "#B58900"
        },
        {
            "background": "#FDF6E3",
            "black": "#002B36",
            "blue": "#268BD2",
            "brightBlack": "#073642",
            "brightBlue": "#839496",
            "brightCyan": "#93A1A1",
            "brightGreen": "#586E75",
            "brightPurple": "#6C71C4",
            "brightRed": "#CB4B16",
            "brightWhite": "#FDF6E3",
            "brightYellow": "#657B83",
            "cursorColor": "#002B36",
            "cyan": "#2AA198",
            "foreground": "#657B83",
            "green": "#859900",
            "name": "Solarized Light",
            "purple": "#D33682",
            "red": "#DC322F",
            "selectionBackground": "#FFFFFF",
            "white": "#EEE8D5",
            "yellow": "#B58900"
        },
        {
            "background": "#000000",
            "black": "#000000",
            "blue": "#3465A4",
            "brightBlack": "#555753",
            "brightBlue": "#729FCF",
            "brightCyan": "#34E2E2",
            "brightGreen": "#8AE234",
            "brightPurple": "#AD7FA8",
            "brightRed": "#EF2929",
            "brightWhite": "#EEEEEC",
            "brightYellow": "#FCE94F",
            "cursorColor": "#FFFFFF",
            "cyan": "#06989A",
            "foreground": "#D3D7CF",
            "green": "#4E9A06",
            "name": "Tango Dark",
            "purple": "#75507B",
            "red": "#CC0000",
            "selectionBackground": "#FFFFFF",
            "white": "#D3D7CF",
            "yellow": "#C4A000"
        },
        {
            "background": "#FFFFFF",
            "black": "#000000",
            "blue": "#3465A4",
            "brightBlack": "#555753",
            "brightBlue": "#729FCF",
            "brightCyan": "#34E2E2",
            "brightGreen": "#8AE234",
            "brightPurple": "#AD7FA8",
            "brightRed": "#EF2929",
            "brightWhite": "#EEEEEC",
            "brightYellow": "#FCE94F",
            "cursorColor": "#000000",
            "cyan": "#06989A",
            "foreground": "#555753",
            "green": "#4E9A06",
            "name": "Tango Light",
            "purple": "#75507B",
            "red": "#CC0000",
            "selectionBackground": "#FFFFFF",
            "white": "#D3D7CF",
            "yellow": "#C4A000"
        },
        {
            "background": "#000000",
            "black": "#000000",
            "blue": "#000080",
            "brightBlack": "#808080",
            "brightBlue": "#0000FF",
            "brightCyan": "#00FFFF",
            "brightGreen": "#00FF00",
            "brightPurple": "#FF00FF",
            "brightRed": "#FF0000",
            "brightWhite": "#FFFFFF",
            "brightYellow": "#FFFF00",
            "cursorColor": "#FFFFFF",
            "cyan": "#008080",
            "foreground": "#C0C0C0",
            "green": "#008000",
            "name": "Vintage",
            "purple": "#800080",
            "red": "#800000",
            "selectionBackground": "#FFFFFF",
            "white": "#C0C0C0",
            "yellow": "#808000"
        }
    ],
    "tabWidthMode": "compact",
    "theme": "dark"
}

以上是关于大家都在点赞 Windows Terminal,我决定给你泼一盆冷水的主要内容,如果未能解决你的问题,请参考以下文章

玩转 Windows Terminal

如何使用Windows Terminal并将它加入你的右键菜单

手把手教你美化微软的新终端Windows Terminal

MongoDB点赞和吐槽功能

在桌面打开网上邻居点整个网络,在点开Microsoft windows network

怎样把gnome-terminal中的内容复制到windows下