Windows Terminal 的 WSL 配置

我在考虑将自己的笔记本从 macOS 转为 Windows,所以就开始研究 Windows 下我常用的软件的替代品,于是,便试了试 Windows Subsystem For Linux ,这一试,发现 WSL 的确不错,很好用,便下载了 Windows Terminal ,作为自己的新的开发环境。

在使用 Windows Terminal 的时候,我遇见了一个问题,我希望在 Windows Terminal 中添加一个新的配置文件,从而让我的 Windows Terminal 在启动的时候就自动进入 Linux 子系统,因此,在互联网上搜索了一些教程后,我将我自己的配置改成了这个样子的。

{
    "globals" : 
    {
        "alwaysShowTabs" : true,
        "copyOnSelect" : false,
        "defaultProfile" : "{58ad8b0c-3ef8-5f4d-bc6f-13e4c00f2530}",
        "initialCols" : 120,
        "initialRows" : 30,
        "keybindings" : 
        [
            {
                "command" : "closePane",
                "keys" : 
                [
                    "ctrl+shift+w"
                ]
            }
        ],
        "requestedTheme" : "system",
        "showTabsInTitlebar" : true,
        "showTerminalTitleInTitlebar" : true,
        "wordDelimiters" : " ./\\()\"'-:,.;<>~!@#$%^&*|+=[]{}~?\u2502"
    },
    "profiles" : 
    [
        {
            "acrylicOpacity" : 0.5,
            "background" : "#012456",
            "closeOnExit" : true,
            "colorScheme" : "Campbell",
            "commandline" : "powershell.exe",
            "cursorColor" : "#FFFFFF",
            "cursorShape" : "bar",
            "fontFace" : "Consolas",
            "fontSize" : 12,
            "guid" : "{61c54bbd-c2c6-5271-96e7-009a87ff44bf}",
            "historySize" : 9001,
            "icon" : "ms-appx:///ProfileIcons/{61c54bbd-c2c6-5271-96e7-009a87ff44bf}.png",
            "name" : "Windows PowerShell",
            "padding" : "0, 0, 0, 0",
            "snapOnInput" : true,
            "startingDirectory" : "%USERPROFILE%",
            "useAcrylic" : false
        },
        {
            "acrylicOpacity" : 0.75,
            "closeOnExit" : true,
            "colorScheme" : "One Half Dark",
            "commandline" : "debian",
            "cursorColor" : "#FFFFFF",
            "cursorShape" : "bar",
            "fontFace" : "Consolas",
            "fontSize" : 11,
            "guid" : "{58ad8b0c-3ef8-5f4d-bc6f-13e4c00f2530}",
            "historySize" : 9001,
            "icon" : "ms-appx:///ProfileIcons/{9acb9455-ca41-5af7-950f-6bca1bc9722f}.png",
            "name" : "Debian Path",
            "padding" : "0, 0, 0, 0",
            "startingDirectory" : "/home/bestony",
            "snapOnInput" : true,
            "useAcrylic" : true
        }
    ],
    "schemes" : 
    [
        {
            "background" : "#282C34",
            "black" : "#282C34",
            "blue" : "#61AFEF",
            "brightBlack" : "#5A6374",
            "brightBlue" : "#61AFEF",
            "brightCyan" : "#56B6C2",
            "brightGreen" : "#98C379",
            "brightPurple" : "#C678DD",
            "brightRed" : "#E06C75",
            "brightWhite" : "#DCDFE4",
            "brightYellow" : "#E5C07B",
            "cyan" : "#56B6C2",
            "foreground" : "#DCDFE4",
            "green" : "#98C379",
            "name" : "One Half Dark",
            "purple" : "#C678DD",
            "red" : "#E06C75",
            "white" : "#DCDFE4",
            "yellow" : "#E5C07B"
        }
    ]
}

这个配置项目中,需要注意的是 profiles.[1].commandline 你会发现,我设置的是 debian 这个和很多教程是不一样的,不少教程使用的是 wsl -d debian 这样的,但是实际上,如果你使用的是 wls -d debian ,你会发现,你配置的 startingDirectory 就会失效,但是如果你的启动命令是 debian, 不会影响你的 startingDirectory 的配置,非常舒服。

Reference

  • https://lwz322.github.io/2019/06/01/Terminal.html
  • https://github.com/microsoft/terminal/issues/1183

发表评论