OTZ
OTZ

Reputation: 3083

How can I copy the selection to the clipboard automatically in the GNOME terminal?

I want to make the GNOME terminal behave in such a way that when the end user selects a region on the terminal (with a mouse or mouse key), it gets automatically copied into the clipboard. Is it possible at all? If so, how?

Upvotes: 59

Views: 67139

Answers (10)

simon
simon

Reputation: 5935

You can also install PuTTY that has pterm, a terminal emulator that is part of the PuTTY tools, that allows for the current selection to be pasted with a middle button click.

Upvotes: -1

statquant
statquant

Reputation: 14400

On my Fedora 23, with GNOME terminal 3.18.3

  • <Shift>+Selection for line
  • <Shift>+<Ctrl>+Selection for block

Once this is done, you can use:

  • <Shift>+<Insert> to insert in another terminal
  • the middle click everywhere else.

Upvotes: 5

Matt Thomas
Matt Thomas

Reputation: 1

I use Debian 7 (Wheezy) and GNOME terminal and found a good solution is to install xsel which provides the correct copy function in the terminal.

Mouse-left-drag to select/copy text to clipboard, and I paste into Vim using Shift + Insert keys, which are defined in the GNOME terminal menu* → EditKeyboard shortcuts. You can define alternative keys if wanted.

Upvotes: 0

Christos
Christos

Reputation: 161

When using Clipit, right click → PreferencesSettings: Check: Use Primary selections and Synchronize clipboards.

It is also possible to use shortcut "Ctrl grave" for Manage hotkey (grave is the `), if you were used to ditto from Windows. If not, it’s handy anyway to have all your previous copies at hand and searchable.

Upvotes: 16

fijiaaron
fijiaaron

Reputation: 5195

It used to be the default behavior in the GNOME terminal as well, but then usability experts got ahold of Linux distributions, and deemed copy & paste to be too risky an activity for kernel hackers to be involved in.

But on Fedora (at least) it recently came back. Right-click in your terminal, go to "input method", and select "X input method". You now have highlight to copy.

If you have a three-button mouse, it can be pasted with the middle button (as mentioned above), but to get right-click paste—well, um...

Upvotes: 3

St&#233;phane
St&#233;phane

Reputation: 3934

I've been searching for a long time a way to emulate PuTTY's behavior in the default Ubuntu terminal:

  • left-click to select text and copies it into the clipboard
  • right-click to paste the content of the clipboard

The only solution I found, which works perfectly, is to patch the Gnome terminal (as you already guessed it).

Upvotes: 2

fastmultiplication
fastmultiplication

Reputation: 3091

It's possible.

sudo apt-get install parcellite

Then in the settings, check "use primary" and "synchronize clipboards". It works.

Upvotes: 54

CGL
CGL

Reputation: 1

My Answer on superuser: https://superuser.com/a/1721880/1694169

Adding this to ~/.Xresources (create if it doesn't exist) worked for me:

xterm*selectToClipboard: true

Just Log out and back in or do a restart. Selected text will then be automatically copied and you can paste it with middle-click (when middle-click is enabled in Gnome-Tweaks)

Upvotes: 0

Bruce van der Kooij
Bruce van der Kooij

Reputation: 2212

As you seem to be coming from a Windows environment I hope you are aware that the way copying and pasting works under X is a bit different from how it works under Windows. If not, for a quick introduction see Jamie Zawinski's excellent article on this subject matter X Selections, Cut Buffers, and Kill Rings.

In short: when you select some text this becomes the Primary selection (not the Clipboard selection). As others have pointed out you can paste from the Primary selection using the middle mouse button. Note however that if you close the application offering the selection, in your case the terminal, the selection is essentially "lost".

You can also use Shift+Ctrl+C in Gnome Terminal to explicitly "copy" something.

Upvotes: 9

unutbu
unutbu

Reputation: 880877

It should be in the X11 clipboard. (Not the same as the GTK clipboard). Press middle-click to paste.

Upvotes: 44

Related Questions