我有一个 bin,它以stdout
以下格式输出主机名(通常约为 20 行):
ldn0000000002;ldn0000000040;ldn00000000055;ldn0000000117;nyk0000000001;nyk0000000002;tky0000000001
然后我会调查其中的几个ssh <hostname>
(例如ssh ldn0000000117
)。使用、、、、、进行复制和粘贴Ctrl+[
,arrow-keys
然后会space
花费我大量的时间来突出显示我想要复制的文本。arrow-keys
space
Ctrl+]
是否有可能存在类似于自动完成的功能,我只需键入l
并按下某个键(例如tab
),它就会提供ldn0000000
给 Windows 输入队列(如:history
aka Ctrl+{
),然后点击1
(现在ldn00000001
)tab
即可完成ldn0000000117
?
输出可以通过管道传输到任何 bin(例如sed
)以重新格式化为换行符分隔或任何格式(如果需要)。
arrow-keys
我们也欢迎消除需要的替代解决方案!
我没有主机的所有权,所以我无法更改远程主机上的任何文件。
答案1
我不知道如何自动完成。所以,替代计划是改进你的光标移动。
在复制/回滚模式下,您可以使用一些移动键。(来自screen(1)
)
Movement keys:
h, C-h, or left arrow move the cursor left.
j, C-n, or down arrow move the cursor down.
k, C-p, or up arrow move the cursor up.
l ('el') or right arrow move the cursor right.
0 (zero) or C-a move to the leftmost column.
+ and - positions one line up and down.
H, M and L move the cursor to the leftmost column of the top, center or bottom line of the window.
| moves to the specified absolute column.
g or home moves to the beginning of the buffer.
G or end moves to the specified absolute line (default: end of buffer).
% jumps to the specified percentage of the buffer.
^ or $ move to the leftmost column, to the first or last non-whitespace character on the line.
w, b, and e move the cursor word by word.
B, E move the cursor WORD by WORD (as in vi).
f/F, t/T move the cursor forward/backward to the next occurence of the target. (eg, '3fy' will move the cursor to the 3rd 'y' to the right.)
; and , Repeat the last f/F/t/T command in the same/opposite direction.
C-e and C-y scroll the display up/down by one line while preserving the cursor position.
C-u and C-d scroll the display up/down by the specified amount of lines while preserving the cursor position. (Default: half screen-full).
C-b and C-f scroll the display up/down a full screen.
Searching:
? Vi-like search backward.
C-a s Emacs style incremental search forward.
C-r Emacs style reverse i-search.
n Find next search pattern.
N Find previous search pattern.
就你的情况来说,
Ctrl+[
- 进入复制/回滚模式。?ldn
ldn
-从当前光标位置向后搜索一个单词。n
- 移动光标至下一个候选项。space
(当光标位置移动到您希望的位置时)设置第一个标记。e
- 将光标移动到单词末尾。space
- 设置第二个标记并结束复制/回滚模式。
箭头键不会出现在任何地方。:)