关于ssh:Win10下的最好免费ssh客户端WIndows-Terminal

55次阅读

共计 3939 个字符,预计需要花费 10 分钟才能阅读完成。

总述

做为一个码农,根本工作就是登录到 linux 服务器上干活。尽管有 VNC 可用,但架不住图形界面怎么都不如终端晦涩啊,所以大多数时候还是用 ssh 登录到服务器在终端下编码, 编译, 运行。
收费的 ssh 客户端还是有的,之前也用过 putty(及各种变种),podarosa, mobaxterm, xshell。
之前 xshell 的免费版是没限度的,xshell 是所有 ssh 客户端中最好用的,所以始终想买个正版反对一下,无奈这货真有点贵,99 美刀一年。
无意之中有人提了一嘴 windows terminal, 这一翻折腾后,发现居然想要的性能居然都不缺,在某些方面应该比 xshell 还容易定制,要害是能够配置的十分丑陋,齐全不逊于 xshell。

装置

最不便的形式是从 Microsoft Store 装置。
如果从 github release page 装置的话,则无奈自动更新

win10 曾经内嵌 ssh client,无需装置,能够间接应用

启动

在搜寻框里间接输出 windows terminal 就会有相应的 app

个性

  • 多标签页(能够通过 ctrl+shift+t 来关上新的标签页,或通过 + 旁边的按钮)
  • 多面板

    • alt+shift++: 关上垂直面板
    • alt+shift+-: 关上程度面板
    • alt+shift+D: 关上一个和目前一样的面板
  • 可配置字体,配色计划
  • 可配置快捷键
  • 可设定命令或字符片断

配置

通过 ctrl+, 能够关上用户配置文件,json 格局

快捷键

根本构造就是 command 和 keys

 "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"
        },
        {
            "command": 
            {
                "action": "switchToTab",
                "index": 0
            },
            "keys": "alt+1"
        },
        {
            "command": 
            {
                "action": "switchToTab",
                "index": 1
            },
            "keys": "alt+2"
        },
        {
            "command": 
            {
                "action": "switchToTab",
                "index": 2
            },
            "keys": "alt+3"
        },
        {
            "command": 
            {
                "action": "switchToTab",
                "index": 3
            },
            "keys": "alt+4"
        },
        {
            "command": 
            {
                "action": "switchToTab",
                "index": 4
            },
            "keys": "alt+5"
        },
        {
            "command": 
            {
                "action": "switchToTab",
                "index": 5
            },
            "keys": "alt+6"
        },
        {
            "command": 
            {
                "action": "switchToTab",
                "index": 6
            },
            "keys": "alt+7"
        },
        {
            "command": 
            {
                "action": "switchToTab",
                "index": 7
            },
            "keys": "alt+8"
        },
        {
            "command": 
            {
                "action": "switchToTab",
                "index": 8
            },
            "keys": "alt+9"
        },
        {
            "command":
            {
                "action": "closeTab",
                "index": 100
            },
            "keys": "ctrl+shift+w"
        },
        {
            "command":
            {
             // use \n for linux
                "action": "sendInput",
                "input": "source ~/.uzsh/xlm20.zshrc\n"
            },
            "keys": "ctrl+1"
        },
        {
            "command":
            {
             // use \r for windows
                "action": "sendInput",
                "input": "ssh -t harriszh@sw02 \"zsh\"\r"
            },
            "keys": "ctrl+2"
        },
        // 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"
        }
    ],

命令和代码片断

如下面所标,有一个非凡的命令是 sendInput, 能够通过这个命令来做一个定制化别名
留神在 linux 下用 \n 做换行,而在 windows 下用 \r 做换行

        {
            "command":
            {
             // use \n for linux
                "action": "sendInput",
                "input": "source ~/.uzsh/xlm20.zshrc\n"
            },
            "keys": "ctrl+1"
        },
        {
            "command":
            {
             // use \r for windows
                "action": "sendInput",
                "input": "ssh -t harriszh@sw02 \"zsh\"\r"
            },
            "keys": "ctrl+2"
        },

抉择复制

像 linux 一样,一旦选中文字就拷贝到零碎粘贴板

"copyOnSelect": true,

profiles

这里定义了几个全局配置, 它们命运对应ctrl+shift+<n>

    "profiles": 
    {"defaults": {},
        "list": 
        [
            {
                "acrylicOpacity": 1.0,
                "colorScheme": "Gruvbox Dark",
                "commandline": "powershell.exe",
                "fontFace": "DejaVuSansMono Nerd Font Mono",
                "guid": "{61c54bbd-c2c6-5271-96e7-009a87ff44bf}",
                "hidden": false,
                "name": "Windows PowerShell",
                "useAcrylic": true
            },
            {
                "commandline": "cmd.exe",
                "experimental.retroTerminalEffect": true,
                "fontFace": "Consolas",
                "foreground": "#00FF00",
                "guid": "{0caa0dad-35be-5f56-a8ff-afceeeaa6101}",
                "hidden": false,
                "name": "Command Prompt"
            },
            {"commandline": "ssh -t harriszh@sw02 \"cd /lan/harriszh && zsh\"","fontFace":"DejaVuSansMono Nerd Font Mono","guid":"{3b6e258c-bd69-43af-9365-69b153b0ece6}","name":"sw02","colorScheme":"Gruvbox Dark","tabTitle":"sw02","useAcrylic": false,"acrylicOpacity": 0.5,
            },
            {}]
    },

配色计划

如下面设置中有一项为colorScheme,window terminal 内嵌一些计划,更多的能够网上搜寻,我比较满意的是Gruvbox Dark.

    "schemes": 
    [
        {
            "background": "#1E1E1E",
            "black": "#1E1E1E",
            "blue": "#377375",
            "brightBlack": "#7F7061",
            "brightBlue": "#719586",
            "brightCyan": "#7DB669",
            "brightGreen": "#AAB01E",
            "brightPurple": "#C77089",
            "brightRed": "#F73028",
            "brightWhite": "#E6D4A3",
            "brightYellow": "#F7B125",
            "cursorColor": "#E6D4A3",
            "cyan": "#578E57",
            "foreground": "#E6D4A3",
            "green": "#868715",
            "name": "Gruvbox Dark",
            "purple": "#A04B73",
            "red": "#BE0F17",
            "selectionBackground": "#E6D4A3",
            "white": "#978771",
            "yellow": "#CC881A"
        },
  ]

成果

如果下所示,彩色系下十分清晰。字体是 nerd 字体,这须要从网上下载,这样能够显示一些如文件夹,文件,图形之类的符号

总结

通过下面的配置后,对于 ssh 到服务器工作这件事曾经入不敷出,而且各种快捷键十分不便。

还有一些其余技巧能够查看官网网页
如有一些其余需要和倡议,欢送留言。

正文完
 0