45

I was wondering if there are shortcuts for selecting some text in terminal, just similar to holding shift and type arrow key in editing a text file in a text editor. Thanks!

Tim
  • 26,107

3 Answers3

15

I'm assuming you are referring to Gnome Terminal.

No - there isnt a Copy and Paste mechanism using just the keyboard - you can use various short-cuts to paste (depending upon your Ubuntu version) i.e. CTRL+ Shift + Ins , Shift + Ins or CTRL+ Shift + V to paste text in the clipboard.

However, if you type screen you enter the terminal emulator which allows you to select, copy and paste text using just the keyboard.

To select (copy):

Press Ctrl + A together followed by Escape. This puts you into Copy mode. Using the cursor keys move to the beginning of the text you want to copy. Press Enter. Now move to the end of the text to be copied. Press Enter.

To Paste:

Press Ctrl + A together followed by ].

fossfreedom
  • 174,526
2

A bit late for the party but yes there is a way.

  1. Replace the rodent with number pad navigation.

    Settings -> Universal Access -> Pointing & Clicking -> Enable Mouse Keys

    You can now use the 4 to go left, 8 to go up, 5 to click etc. (make sure NumLock is OFF).

    NOTE: For this to work you need a NumberPad.

  2. Moving the mouse with the number pad is going to be dog slow so lets fix that next. See man page for xkbset for details.

    sudo apt-get install xkbset

    xkbset ma 60 10 10 5 2

    Now you should be able to use the NumberPad to move your cursor at a reasonable speed, so move it to the terminal where you want to select the text.

  3. To select the text in the terminal to the right of the pointer:

    Ctrl+Shift+5+6

    This is equivalent to mouse click=5, go right=6

    To select to the right of the cursor:

    Ctrl+Shift+5+4

Greenonline
  • 2,182
1

In gnome-terminal running bash as default shell, you can hit c-x twice (c- same as ctrl-) to select the last typed text.

Refer to bash reference for more.

fsaulo
  • 11