Please enable Javascript to view the contents

终端工具WindTerm使用

 ·  ☕ 6 分钟

重要

最重要的事:

1.简介

1.2 本地模式

WindTerm有两种模式:

  • 远程模式
    WindTerm的远程模式是默认的模式。 在远程模式下,每个键按下发送到服务器就像其他终端。

  • 本地模式
    本地模式主要用于浏览文本。 在本地模式下,每个键按下将解析本地,而不是发送到服务器。

    支持大多数本地模式 导航 滚动 搜索 复制和粘贴 选择 折叠 Vim的捷径。

    当WindTerm在本地模式下,它就像一个只读的文本编辑器,这是非常方便的文本浏览。 特别是,快速滚动,不断输出时,切换到本地模式可以输出的立即停止滚动,方便阅读。

快捷方式行动
Alt + Enter远程和本地模式切换(Toggle the remote and local mode)
i切换回远程模式(Switch back to remote mode from local mode)
p粘贴、切换回远程模式(Paste and switch back to remote mode from local mode)
Ctrl + v粘贴、切换回远程模式(Paste and switch back to remote mode from local mode)

本地模式Vim导航键说明

ShortcutAction
h左移(Move left)
j下移(Move down)
k上移(Move up)
l右移(Move right)
0行首(Move to the begining of the line)
$行尾(Move to the end of the line)
^行首非空字符(Move to the first non-blank character of the line)
w下一个单词(Move to next word)
W下一个空白分隔词(Move to next blank delimited word)
b词首(Move to the beginning of the word)
B空白分隔词首(Move to the beginning of the blank delimted word)
e词尾(Move to the end of the word)
E空白分隔词尾(Move to the end of the blank delimited word)
1G首行(Move to the first line of the session)
nGN行(Move to nth line of the session)
G尾行(Move to the last line of the session)
gg开头(move to the beginning of the session)
ge行尾单词,词首(Move to the end of the previous word)
gEMove to the end of the previous Blank delimited word
-非空句首(Move to the previous non-blank sentence)
+非空句尾(Move to the next non-blank sentence)
(句首(Move to the previous sentence)
)句尾(Move to the next sentence)
{段首(Move to the previous paragraph)
}段尾(Move to the next paragraph)

本地模式Vim文本复制说明

在本地模式下,可以使用y{motion}复制,其中{motion}是上面导航快捷键或搜索快捷键。例如,yw 复制下一个单词的开头。其他有用的副本命令包括:

快捷键动作
yy复制当前行,包括换行符、新行起始字符(如hex@hex-ThinkPad:~$);复制选中内容
y$复制当前行,不包括换行符、新行起始字符
yw复制到下一个单词开头
ytx当前光标位置向后复制至字符x,不包括x
yfx当前光标位置向后复制至字符x, 包括x
p粘贴、并返回Remote模式
P粘贴、并保留Local模式(Vim文本)
“xy{motion}复制内容、并注册给变量x
“xp黏贴变量x中的内容、并返回Remote模式
“xP黏贴变量x中的内容、并保留Local模式(Vim文本)
“+y{motion}复制内容、至系统粘贴板
“+p从系统粘贴板粘贴、并返回Remote模式
“+P从系统粘贴板粘贴、并保留Local模式(Vim文本)

1.2 快捷键记录

快捷键动作
Ctrl+Shift+W关闭页签(Close tab)
Ctrl+Shift+T回复页签(Restore tab)
Ctrl+Shift+Left转至前提示行(Goto the previous prompt line)
Ctrl+Shift+Right转至后提示行(Goto the next prompt line)
Ctrl+Alt+L锁屏
Alt+1选择1页签
Alt+O打开页签
Alt+S搜索页签
  • 批量发送(Sender Pane)快捷键
快捷键动作
Alt+Enter发送(Send)
Alt+Q停止(Stop)
Alt+=增加新的发送记录(Add Sender)
Alt+-删除发送(Remove Sender)
Alt+X清空(Clear Sender)
  • 文件传输(Sftp)快捷键
快捷键动作
Alt+Enter发送(Send)
Alt+Q停止(Stop)
Alt+=增加新的发送记录(Add Sender)
Alt+-删除发送(Remove Sender)
Alt+X清空(Clear Sender)
快捷键动作
F2文件重命名(Rename)
F3文件下载 (Download)
F4文件上传 (Upload)
F5目录刷新 (Refresh)
F6移动至 (Move to)
Del删除 (Remove)
Return打开 (Open)
Backspace返回上一层(Cdup)
Alt+D选中地址栏(Select the address bar)
Alt+Left向前回滚 (Go backward)
Alt+Right向后回滚 (Go forward)
Alt+Return属性 (Show property)
Ctrl+A全选 (Select all items)
Ctrl+Shift+N新建文件夹(Create a folder)
Ctrl+N新建文件 (Create a file)
Ctrl+L新建软链 (Create a link)
Ctrl+C复制名称 (Copy names)
Ctrl+Shift+C复制路径 (Copy paths)
Ctrl+P复制名称至终端(Copy names to terminal)
Ctrl+Shift+P复制名称至终端(Copy paths to terminal)

自动补全

自动补全会提示当前可用的命令、子命令、命令选项、命令参数、历史命令、快捷命令。

自动补全-快捷命令

自动补全支持快捷栏(Alt+w->Alt+Q在底部启用)中快速命令的补全。需要先在快捷命令中创建命令,自动补全索引的是快捷命令的名字。

自动补全-历史命令

历史命令包含同一系统(如 Linux 系统)所有会话的命令历史记录,默认最大数量为 10000 条(30天)。

在Session窗口,可以通过下面两种方式实现历史命令的自动补全:

  • 在行首输入!
  • 或者,通过快捷键Ctrl+R

自由键入模式

自由键入模式:键入shell命令、使用VIM应用程序时,可以使用鼠标移动光标、选择文本、拖放文本。

  • 按住Alt后,在需要的位置点击左键鼠标,即可将游标移动至任意位置(当会话-终端为xtermxterm-256color时,只需要点击鼠标即可);

修改默认快捷键

目前没有自定义快捷键的功能,可以通过手动修改配置文件{应用程序目录}\global\wind.keymaps的方式设置issue-403

修改复制快捷键(注意设置action,防止全局生效导致无法发送取消信号)参考此issue
原配置内容为

1
2
3
4
  { "keys": "<Ctrl+C>",
    "modes": "normal, local",
    "action": "Text.Copy"
  }

修改为

1
2
3
4
5
  { "keys": "<Ctrl+C>",
    "modes": "normal, command, local, remote",
    "when": "window.activeText.isSelectionEmpty() == false",
    "action": "Text.Copy"
  }

修改粘贴快捷键
原配置为:

1
2
3
4
  { "keys": "<Shift+Ins>",
    "modes": "normal, command, local, remote",
    "action": "Text.Paste"
  }

修改为:

1
2
3
4
  { "keys": "<Ctrl+V>",
    "modes": "normal, command, local, remote",
    "action": "Text.Paste"
  }

上面的json对象都是平级,功能取并集。而页面显示的靠后设置的json,可以将需要显示的配置放到文件末尾,让其在页面显示。只影响显示,不影响功能。

本地操作kubectl最佳实践

目前wsl会出现乱码问题,因此不推荐在windows下使用。如果在linux下,通过以下配置

通过不同环境创建不同目录,并在不同目录下保存相应的kubeconfig文件,在shell设置中,将工作目录与环境变量进行设置
shell设置如下图
windterm-shell.png

目录结构仅供参考

1
2
3
4
5
6
kube
   dev
      core
        .kubeconfig
      paas
        .kubeconfig

待解决问题:

  1. 修改稿默认粘贴快捷键为ctrl+c后,导致无法发送取消信号,目前改回默认配置,参考此issue后修改

  2. 打开wsl窗口后,使用vim会出现乱码ESC[0%m。目前通过ssh 127.0.0.1的方式操作wsl.此issue-232issue-1544出现的乱码不同,且也为解决。暂时记录等后续再跟进

Reference

分享

Hex
作者
Hex
CloudNative Developer

目录