Page 1 of 2

Copy any selection to clipboard

Posted: Sun 27 Jul 2014, 14:17
by MochiMoppel
Edit 2013-4-13: I changed the thread title (was: Terminal emulator (urxvt etc.): Copy selection to clipboard) to reflect the fact that my proposal is not restricted to the use in a console. I also added an alternative method which makes copying easier.
---------------------------

Users switching from MS Windows to Linux take it for granted that the keyboard shortcut Ctrl+C will put selected text into the clipboard. Big surprise when in a terminal window like urxvt this doesn't apply anymore.

Experienced users know that Linux holds every selection in a "primary" buffer and that in any application this buffer can be pasted with the middle mouse button or - now it's getting complicated - in a console window also with Shift+Insert.

Still there are many situations where copying terminal text to the clipboard would be useful. The lack of a middle mouse button is only one of them.

Here are 2 simple ways to create a "Copy to Clipboard" shortcut (Ctrl+Shift+C) :

Method 1: Keyboard shortcut with JWM
Step 1: Edit the file /root/.jwm/jwmrc-personal. Add 1 line:
<Key mask="CS" key="c">exec:xclip -o|xclip -sel clip</Key>
Step 2: Restart JWM

Method 2: Keyboard shortcut/desktop icon with ROX
seethis post

Text copied with Ctrl+Shift+C can then be pasted into other applications with the familiar Ctrl+V.

That's it....well, almost:
Above shortcut uses the tool xclip, which is included in all Puppy versions I tested. However even newest Puppy versions use the old xclip version 0.08 (typing xclip -version into a terminal window reveals the version). This version does not support UTF-8 characters and users of languages with funny characters like French, German or Japanese might get pasted ASCII salad instead. See here
As mentioned in the link a new version can be obtained at http://slackware.org.uk/slacky/slackware-14.0/utilities/xclip/0.12/

Download xclip-0.12-i486-2sl.txz , extract the file /usr/bin/xclip (all the other stuff is not important) and copy it to /usr/bin. This will not overwrite the old version which - for obscure reasons - resides in usr/X11R7/bin. When calling xclip Puppy will first look into /usr/bin, will find the new version and will not bother to look any further. Tested in Slacko, Precise and Lupu.

.

Posted: Thu 02 Apr 2015, 08:44
by greengeek
Just wanted to say thanks for this mod - I have been using it for quite a while now and it makes every day so much better!

Posted: Thu 02 Apr 2015, 09:10
by disciple
Experienced users know that Linux holds every selection in a "primary" buffer and that in any application this buffer can be pasted with the middle mouse button or - now it's getting complicated - in a console window also with Shift+Insert.
FWIW there are simple patches to fix gtk 2 and 3 to add this feature.

Posted: Thu 02 Apr 2015, 11:28
by MochiMoppel
greengeek wrote:I have been using it for quite a while now and it makes every day so much better!
Thanks - now we are two :lol:
disciple wrote:FWIW there are simple patches to fix gtk 2 and 3 to add this feature.
Fix what? Add which feature?

Posted: Thu 02 Apr 2015, 11:56
by Jasper
Hi MochiMoppel,

I dare say, at least three. Thank you.

My regards

Posted: Thu 02 Apr 2015, 14:42
by mavrothal
Nice.
If you use xsel instead of xclip and combine it with xdotool you can also paste. :wink:

Posted: Thu 02 Apr 2015, 15:21
by Flash
Highlighting text I want to copy, then simultaneously clicking the left and right mouse buttons to paste it, has worked for me in every version of Puppy I've used. Am I the only one this works for?

Posted: Thu 02 Apr 2015, 16:06
by musher0
disciple wrote:
Experienced users know that Linux holds every selection in a "primary" buffer and that in any application this buffer can be pasted with the middle mouse button or - now it's getting complicated - in a console window also with Shift+Insert.
FWIW there are simple patches to fix gtk 2 and 3 to add this feature.
Hello, disciple.

Stating your sources or a how-to would be most useful!
Thanks in advance. BFN.

musher0

Posted: Thu 02 Apr 2015, 16:07
by musher0
mavrothal wrote:Nice.
If you use xsel instead of xclip and combine it with xdotool you can also paste. :wink:
Thanks for the reference.

Posted: Thu 02 Apr 2015, 16:23
by mavrothal
Flash wrote:Highlighting text I want to copy, then simultaneously clicking the left and right mouse buttons to paste it, has worked for me in every version of Puppy I've used. Am I the only one this works for?
Works for everybody, but middle click will paste at the mouse cursor point, Ctrl-shift-V at the text cursor point :wink:

Posted: Thu 02 Apr 2015, 17:03
by musher0
mavrothal wrote:
Flash wrote:Highlighting text I want to copy, then simultaneously clicking the left and right mouse buttons to paste it, has worked for me in every version of Puppy I've used. Am I the only one this works for?
Works for everybody, but middle click will paste at the mouse cursor point, Ctrl-shift-V at the text cursor point :wink:
Now the man tells us! ;)

Posted: Thu 02 Apr 2015, 18:06
by greengeek
Fantastic!! Mavrothal's link suggested using Shift+Insert as a method to paste into the terminal. Seems to work for me! I previously had to use left and right click simultaneously for the 'paste' function. So now I can use that technique for paste and Mochis mod for copy.

I would be even happier if there was some way to set up "Shift+Ctrl+V" for the paste. Now that I have got used to Mochi's mod it seems so natural for me that adding "Shift" to Ctrl+c lets me copy from terminal, so I'd like to just add "Shift" to Ctrl+v for the paste into terminal.

EDIT : Faceslap !!! Now I see Mochi mentioned Shift+insert in the first post. I can be soooo stoopid. All these months there was an easier way...
:oops:
.
ps: I'd still love to see shift+insert replaced by Shift+Ctrl+v

Posted: Thu 02 Apr 2015, 18:30
by mikeb
yep just noticed the shift insert which for me makes life much easier... especially with some laptops/netbook interfaces... I wonder what we will find out thats been hidden in the next 9 years :D

xbinkeys or xmodmap or something might be useful... but to be honest a mouse free method is a big bonus..no more triple pastes :)

mike

Posted: Thu 02 Apr 2015, 22:32
by disciple
MochiMoppel wrote:
greengeek wrote:I have been using it for quite a while now and it makes every day so much better!
Thanks - now we are two :lol:
disciple wrote:FWIW there are simple patches to fix gtk 2 and 3 to add this feature.
Fix what?
GTK ignoring the standard behaviour in X to paste the Primary Selection with Shift-Insert.
Add which feature?
That one.

Posted: Thu 02 Apr 2015, 22:40
by disciple
musher0 wrote:
disciple wrote:
Experienced users know that Linux holds every selection in a "primary" buffer and that in any application this buffer can be pasted with the middle mouse button or - now it's getting complicated - in a console window also with Shift+Insert.
FWIW there are simple patches to fix gtk 2 and 3 to add this feature.
Hello, disciple.

Stating your sources or a how-to would be most useful!
Thanks in advance. BFN.

musher0
http://murga-linux.com/puppy/viewtopic.php?t=80150

Posted: Fri 03 Apr 2015, 01:36
by musher0
Thanks, disciple.

I did read Mochi's reference, but it sounded like Martian, and it made me
grumpy... I'll re-read it with a rested head tomorrow... ;)

Posted: Fri 03 Apr 2015, 03:12
by disciple
musher0 wrote:Thanks, disciple.

I did read Mochi's reference, but it sounded like Martian, and it made me
grumpy... I'll re-read it with a rested head tomorrow... ;)
I'm assuming when you say "Mochi's reference" that's a slip up?

Re: Terminal emulator (urxvt etc.): Copy selection to clipboard

Posted: Fri 03 Apr 2015, 11:56
by BarryK
MochiMoppel wrote: Above shortcut uses the tool xclip, which is included in all Puppy versions I tested. However even newest Puppy versions use the old xclip version 0.08 (typing xclip -version into a terminal window reveals the version). This version does not support UTF-8 characters and users of languages with funny characters like French, German or Japanese might get pasted ASCII salad instead. See here
As mentioned in the link a new version can be obtained at http://slackware.org.uk/slacky/slackware-14.0/utilities/xclip/0.12/
Thanks for bringing that to my attention!

Quirky April 7.0.2 has xclip 0.11. I have now upgraded to 0.12, which will be in 7.0.3.

Posted: Fri 03 Apr 2015, 16:07
by slavvo67
I have another solution; it's called RoxTerm.

Posted: Fri 03 Apr 2015, 16:52
by musher0
disciple wrote:
musher0 wrote:Thanks, disciple.

I did read Mochi's reference, but it sounded like Martian, and it made me
grumpy... I'll re-read it with a rested head tomorrow... ;)
I'm assuming when you say "Mochi's reference" that's a slip up?
To be clear: you referred to a post by Mochi, and in this post Mochi points
to another site. That Internet page sounded like Martian, not yours, not
Mochi's.

Sorry if I offended anyone, English is not my mother tongue, I may use it
in a clumsy manner at times.

BFN.

musher0