Copy any selection to clipboard

How to do things, solutions, recipes, tutorials
Message
Author
User avatar
MochiMoppel
Posts: 2084
Joined: Wed 26 Jan 2011, 09:06
Location: Japan

Copy any selection to clipboard

#1 Post 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.

.
Last edited by MochiMoppel on Mon 13 Apr 2015, 07:08, edited 1 time in total.

User avatar
greengeek
Posts: 5789
Joined: Tue 20 Jul 2010, 09:34
Location: Republic of Novo Zelande

#2 Post 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!

disciple
Posts: 6984
Joined: Sun 21 May 2006, 01:46
Location: Auckland, New Zealand

#3 Post 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.
Do you know a good gtkdialog program? Please post a link here

Classic Puppy quotes

ROOT FOREVER
GTK2 FOREVER

User avatar
MochiMoppel
Posts: 2084
Joined: Wed 26 Jan 2011, 09:06
Location: Japan

#4 Post 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?

Jasper

#5 Post by Jasper »

Hi MochiMoppel,

I dare say, at least three. Thank you.

My regards

User avatar
mavrothal
Posts: 3096
Joined: Mon 24 Aug 2009, 18:23

#6 Post by mavrothal »

Nice.
If you use xsel instead of xclip and combine it with xdotool you can also paste. :wink:
== [url=http://www.catb.org/esr/faqs/smart-questions.html]Here is how to solve your[/url] [url=https://www.chiark.greenend.org.uk/~sgtatham/bugs.html]Linux problems fast[/url] ==

User avatar
Flash
Official Dog Handler
Posts: 13071
Joined: Wed 04 May 2005, 16:04
Location: Arizona USA

#7 Post 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?

musher0
Posts: 14629
Joined: Mon 05 Jan 2009, 00:54
Location: Gatineau (Qc), Canada

#8 Post 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
musher0
~~~~~~~~~~
"You want it darker? We kill the flame." (L. Cohen)

musher0
Posts: 14629
Joined: Mon 05 Jan 2009, 00:54
Location: Gatineau (Qc), Canada

#9 Post 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.
musher0
~~~~~~~~~~
"You want it darker? We kill the flame." (L. Cohen)

User avatar
mavrothal
Posts: 3096
Joined: Mon 24 Aug 2009, 18:23

#10 Post 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:
== [url=http://www.catb.org/esr/faqs/smart-questions.html]Here is how to solve your[/url] [url=https://www.chiark.greenend.org.uk/~sgtatham/bugs.html]Linux problems fast[/url] ==

musher0
Posts: 14629
Joined: Mon 05 Jan 2009, 00:54
Location: Gatineau (Qc), Canada

#11 Post 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! ;)
musher0
~~~~~~~~~~
"You want it darker? We kill the flame." (L. Cohen)

User avatar
greengeek
Posts: 5789
Joined: Tue 20 Jul 2010, 09:34
Location: Republic of Novo Zelande

#12 Post 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

User avatar
mikeb
Posts: 11297
Joined: Thu 23 Nov 2006, 13:56

#13 Post 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

disciple
Posts: 6984
Joined: Sun 21 May 2006, 01:46
Location: Auckland, New Zealand

#14 Post 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.
Do you know a good gtkdialog program? Please post a link here

Classic Puppy quotes

ROOT FOREVER
GTK2 FOREVER

disciple
Posts: 6984
Joined: Sun 21 May 2006, 01:46
Location: Auckland, New Zealand

#15 Post 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
Do you know a good gtkdialog program? Please post a link here

Classic Puppy quotes

ROOT FOREVER
GTK2 FOREVER

musher0
Posts: 14629
Joined: Mon 05 Jan 2009, 00:54
Location: Gatineau (Qc), Canada

#16 Post 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... ;)
musher0
~~~~~~~~~~
"You want it darker? We kill the flame." (L. Cohen)

disciple
Posts: 6984
Joined: Sun 21 May 2006, 01:46
Location: Auckland, New Zealand

#17 Post 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?
Do you know a good gtkdialog program? Please post a link here

Classic Puppy quotes

ROOT FOREVER
GTK2 FOREVER

User avatar
BarryK
Puppy Master
Posts: 9392
Joined: Mon 09 May 2005, 09:23
Location: Perth, Western Australia
Contact:

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

#18 Post 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.
[url]https://bkhome.org/news/[/url]

slavvo67
Posts: 1610
Joined: Sat 13 Oct 2012, 02:07
Location: The other Mr. 305

#19 Post by slavvo67 »

I have another solution; it's called RoxTerm.

musher0
Posts: 14629
Joined: Mon 05 Jan 2009, 00:54
Location: Gatineau (Qc), Canada

#20 Post 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
musher0
~~~~~~~~~~
"You want it darker? We kill the flame." (L. Cohen)

Post Reply