Windows Terminal

Posted _xk

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了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的主要内容,如果未能解决你的问题,请参考以下文章

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

Windows Terminal

windows terminal 连接远程 ssh

pycharm windows 打开命令行终端terminal

Windows下的终端工具-Terminal

玩转 Windows Terminal