47

If I'm working in a terminal window in Linux, is there a keyboard shortcut I can use to select output displayed on previous lines? If I select something with the mouse I can copy using Ctrl + Shift + C, but is there a way to select without using the mouse at all. I'm using either Gnome terminal or KDE konsole in Ubuntu desktop.

For example I often need to copy results from a mysql query and then google them.

Jasper
  • 2,166
  • 4
  • 30
  • 50
annavt
  • 713
  • 1
  • 6
  • 8
  • 1
    You need to add more details. Are you at a "raw" virtual console, or running a console-emulator in e.g. GNOME or something? – unwind Oct 08 '09 at 09:55
  • 1
    Exact duplicate: http://stackoverflow.com/questions/312213/how-do-i-copy-text-from-my-xterm-without-a-mouse – Nathan Fellman Oct 08 '09 at 09:58

6 Answers6

12

You can use the screen application and enter copy mode with Ctrl+a, Esc. Start selecting text with Space and end selecting text with Space. Insert text with Ctrl+a, ]

Carolus
  • 477
  • 4
  • 16
knittl
  • 246,190
  • 53
  • 318
  • 364
8

Daniel Micay's Termite sports a "selection mode". Pressing Ctrl+Shift+Space will activate it. It's got vim-like key bindings. v or V will select à la vim's visual mode, y will yank, Esc will exit selection mode.

Carolus
  • 477
  • 4
  • 16
Niko
  • 558
  • 5
  • 14
2

Screen and Emacs M-x shell, for example, allow for keyboard access to the scrollback buffer. This was also one of the features of Plan 9 (but I guess it was mouse-oriented, at least primarily); you might want to take a look at 9term and/or Sam, the Plan 9 editor.

tripleee
  • 175,061
  • 34
  • 275
  • 318
1

You can to it at terminal:

1 - Move the cursor to the beginning of line using ctrl + a

 $ touch test.txt  

2 - Copy the line to the paste area ctrl + k

3 - Finally, you can past it ctrl + y

$ touch test.txt                

4- You can do it in a single word or more just using crtl + or crtl + and use crtl + k at word's beginning.

joao silva
  • 19
  • 2
  • Oooh, composition! I was quite sure I was missing something. Now I can use `ctrl-b` to move back too, and use many other emacs movement shortcuts! – dmvianna Mar 27 '23 at 02:09
  • This does not address the question, which is about selecting text so as to be able to copy to the system clipboard (enabling pasting in other applications). Instead, this response answers a different, unasked question, i.e. how to copy and paste using the GNU kill ring. – teraspora Mar 29 '23 at 19:45
-1

If you want to copy the command(which you typed) without using mouse, you can try this ctrl + space + OR .

Now you can select the words.

Fedor
  • 17,146
  • 13
  • 40
  • 131
-3

$ emacs -g '80x24' --eval '(term "/bin/bash")'

    C-c C-k    char mode
    C-c C-j    line mode
    C-space    Selecting text in terminal without using the mouse
    M-w        copy to X11 clipboard

C - Ctrl M - Alt