Gnome-terminal - How to Copy selection to clipboard automatically?

LinuxTerminalGnome

Linux Problem Overview


I want to make 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?

Linux Solutions


Solution 1 - Linux

it's possible.

sudo apt-get install parcellite

then in the settings check "use primary" and "synchronize clipboards". it works.

Solution 2 - Linux

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

Solution 3 - Linux

SOLVED: when using Clipit . Right click / Preferences / Settings : check: Use Primary selections and Synchronize clipboards.

It is also possible to put shortcut "Ctrl grave" for Manage hotkey (grave is the `), if you were used to Ditto from windows. If not, its handy anyways to have all your previous copies at hand and searchable.

Solution 4 - Linux

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.

Solution 5 - Linux

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.

Solution 6 - Linux

It used to be the default behavior in gnome-terminal as well -- but then usability experts got ahold of Linux distros, 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 and 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...

Solution 7 - Linux

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).

Solution 8 - Linux

You can also install pterm a Putty like terminal emulator, that allows for the current selection to be pasted with a middle button click.

Solution 9 - Linux

I use Debian 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 Gnome terminal menu, edit, keyboard shortcuts. You can define alternative keys if wanted.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionOTZView Question on Stackoverflow
Solution 1 - LinuxfastmultiplicationView Answer on Stackoverflow
Solution 2 - LinuxunutbuView Answer on Stackoverflow
Solution 3 - LinuxChristosView Answer on Stackoverflow
Solution 4 - LinuxBruce van der KooijView Answer on Stackoverflow
Solution 5 - LinuxstatquantView Answer on Stackoverflow
Solution 6 - LinuxfijiaaronView Answer on Stackoverflow
Solution 7 - LinuxStéphaneView Answer on Stackoverflow
Solution 8 - LinuxsimonView Answer on Stackoverflow
Solution 9 - LinuxMatt ThomasView Answer on Stackoverflow