天天看點

Windows Terminal 使用 PuTTY 連接配接 COM 序列槽

Windows Terminal 支援 PowerShell、cmd、Azure Could、WSL、ssh,界面美觀流暢,配置選項豐富,一經推出廣受好評。美中不足的是無法支援 COM 序列槽通信。

經過一番摸索,似乎可以借助 PuTTY 的 PLINK.EXE 曲線救國,隻要載入 PuTTY 之前儲存的 Session 即可。

注:PUTTY.EXE 本身是純 GUI,不可用于 Windows Terminal,但是 PLINK.EXE 可以。

假設在 PuTTY 中連接配接 COM 序列槽的 Session 儲存為 “PuTTY COM Session”,則需要在 Terminal 的 setting.json 中添加如下内容:

{
  "commandline": "D:\\putty\\PLINK.EXE -load \"PuTTY COM Session\"",
  "guid": "{141d171c-4fd9-426d-9008-8cbc4b0b05d3}",
  "hidden": false,
  "icon": "ms-appx:///ProfileIcons/{9acb9455-ca41-5af7-950f-6bca1bc9722f}.png",
  "name": "putty-com-session"
},
           

完整 Terminal 配置如下供參考。

{
    "$schema": "https://aka.ms/terminal-profiles-schema",
    "copyFormatting": "none",
    "copyOnSelect": true,
    "defaultProfile": "{9ac0fc3b-62f8-4fcd-b477-71f164a6ad82}",
    "profiles": 
    {
        "defaults": 
        {
            "acrylicOpacity": 0.90000000000000002,
            "antialiasingMode": "cleartype",
            "bellStyle": 
            [
                "audible",
                "taskbar"
            ],
            "colorScheme": "Ubuntu",
            "cursorShape": "vintage",
            "font": 
            {
                "face": "Ubuntu Mono"
            }
        },
        "list": 
        [
            {
                "commandline": "ssh zijian@zijian-vm",
                "guid": "{9ac0fc3b-62f8-4fcd-b477-71f164a6ad82}",
                "icon": "ms-appx:///ProfileIcons/{9acb9455-ca41-5af7-950f-6bca1bc9722f}.png",
                "name": "LinuxVM",
                "startingDirectory": "%USERPROFILE%"
            },
            {
                "commandline": "powershell.exe",
                "guid": "{61c54bbd-c2c6-5271-96e7-009a87ff44bf}",
                "hidden": false,
                "name": "Windows PowerShell"
            },
            {
                "commandline": "cmd.exe",
                "guid": "{0caa0dad-35be-5f56-a8ff-afceeeaa6101}",
                "hidden": true,
                "name": "\u547d\u4ee4\u63d0\u793a\u7b26"
            },
            {
                "guid": "{b453ae62-4e3d-5e58-b989-0a998ec441b8}",
                "hidden": true,
                "name": "Azure Cloud Shell",
                "source": "Windows.Terminal.Azure"
            },
            {
                "commandline": "C:\\Users\\zijian\\Downloads\\putty\\PLINK.EXE -load \"Default Settings\"",
                "guid": "{141d171c-4fd9-426d-9008-8cbc4b0b05d3}",
                "hidden": true,
                "icon": "ms-appx:///ProfileIcons/{9acb9455-ca41-5af7-950f-6bca1bc9722f}.png",
                "name": "putty-session"
            },
            {
                "commandline": "C:\\Users\\zijian\\Downloads\\putty\\PLINK.EXE -load \"COM\"",
                "guid": "{323f60e8-afd4-45a8-8f57-b593b66c7874}",
                "icon": "ms-appx:///ProfileIcons/{9acb9455-ca41-5af7-950f-6bca1bc9722f}.png",
                "name": "PuTTY-COM"
            }
        ]
    },
    "schemes": 
    [
        {
            "background": "#2E3436",
            "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": "#D3D7CF",
            "green": "#13A10E",
            "name": "Ubuntu",
            "purple": "#881798",
            "red": "#C50F1F",
            "selectionBackground": "#FFFFFF",
            "white": "#CCCCCC",
            "yellow": "#C19C00"
        }
    ],
    "showTabsInTitlebar": true,
    "trimBlockSelection": true,
    "useAcrylicInTabRow": false
}