问题描述
我想使用从另一个xterm中的命令行运行的命令的输出的一部分,或者作为不同命令的一部分。例如:
I want to use part of the output of a command run from the command line in another xterm, or as part of a different command. For instance:
> grep error error.log
error: can't find file ~/<some very long path>/thisfile
我想这样做:
>ls ~/<some very long path>/
我知道两种方法:
1. copy 〜/<一些很长的路径> /
。
2.使用 head
/ tail
/ awk
/ sed
/ perl
/ cut
/ etc ...仅从输出中提取所需内容,然后使用 >里面的反引号。
I know two ways to do this:
1. copy ~/<some very long path>/
with the mouse.
2. use some combination of head
/tail
/awk
/sed
/perl
/cut
/etc... to extract only what I need from the output and then use that inside backticks.
有没有办法在不使用鼠标的情况下复制文本?我想到的例子是VIM中的视觉模式,但我不知道如何在xterm里面做。
Is there any way to copy text without using the mouse? The example that comes to mind is visual mode inside VIM, but I don't know how to do that inside the xterm.
推荐答案
您可以使用GNU屏幕的复制和粘贴命令。
You can use GNU screen's copy and paste commands.
快速教程:
- 打开屏幕:
screen
(或screen myprog my args here
) - 将光标移动到起点 $ <$ li>
- 输入复制模式: b $ b
- 输入
- 将光标移至结束点
- 粘贴:^ A]
- Open screen:
screen
(orscreen myprog my args here
) - Run your program, producing output you want copied
- Enter copy mode: ^A [
- Move your cursor to the start point
- Hit enter
- Move your cursor to the end point
- Hit enter
- Paste: ^A ]
屏幕功能强大得多(我使用它来标记多个虚拟终端,终端仿真器,并且也使得我不松开我的会话,当X崩溃或某事)。要退出屏幕,只需结束shell会话,或键入^ A ^。
Screen is much more powerful than that (I use it to tab several virtual terminals without the need for a special terminal emulator, and also so that I don't loose my sessions when X crashes or something). To get out of screen, simply end your shell session, or type ^A ^.
这篇关于如何在没有鼠标的情况下从我的xterm复制文本?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!