Copy any selection to clipboard

How to do things, solutions, recipes, tutorials
Message
Author
musher0
Posts: 14629
Joined: Mon 05 Jan 2009, 00:54
Location: Gatineau (Qc), Canada

#21 Post by musher0 »

slavvo67 wrote:I have another solution; it's called RoxTerm.
Thanks, but disciple had mentioned it already.
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

#22 Post by greengeek »

Mochi's syntax to copy the terminal selection into the clipboard via Shift+Ctrl+c is as follows:

Code: Select all

<Key mask="CS" key="c">exec:xclip -o|xclip -sel clip</Key>
This works fine on my system. I now also know I can use Shift+Insert to do the opposite - paste the clipboard into the terminal.

I would like to set up a keyboard shortcut similar to Mochi's but the other way around - I want to copy the clipboard into the terminal using the Shift+Ctrl+v shortcut. I have tried the following without success:

Code: Select all

<Key mask="CS" key="v">exec:xdotool key shift+Insert</Key>
The syntax appears right (when I manually enter it into a terminal to see what it does) but it doesn't seem to work when I am working in a terminal, or in geany. I'm very hazy about the difference between primary selection, secondary selection, and clipboard selection - is my syntax failing to select the correct destination buffer before pasting? Am I totally going in the wrong direction?

Also - I notice a slight difference between:

Code: Select all

xdotool key shift+Insert
and

Code: Select all

xdotool key Shift+Insert
The latter syntax (using capital 's') seems to operate twice.

Can anyone suggest a way to activate the shift+ctrl+v shortcut to paste the clipboard into the terminal?

I also tried the following but I'm totally stabbing in the dark here:

Code: Select all

<Key mask="CS" key="v">exec:xclip -i|xclip -sel prim</Key>

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

#23 Post by MochiMoppel »

greengeek wrote:I now also know I can use Shift+Insert to do the opposite - paste the clipboard into the terminal.
No, you can't. That's why I said that it's getting complicated. You can paste the (primary) selection into a terminal with Shift+Insert, but not the clipboard content. In an ordinary application window it's the other way round: Shift+Insert can't paste the primary selection, instead it pastes the clipboard content.

As a gentle reminder: My subject here is copy, not paste. I know that they are related and I admit that pasting is a much more interesting subject, but with pasting clipboard/primary selection to/from terminal window/application window using mouse/keyboard offering endless opportunities for questions (and confusion) I would rather like to keep it separate.

I suggest to post questions related to paste in the recent thread keyboard shortcuts to copy/cut & paste urxvt text?

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

#24 Post by musher0 »

Hello Mochi.

In any case, thanks to you and BarryK's reminder, I have a brand new
xclip installed in my Puppy. :)

As for me, I find it easier to highlight in the console (by dragging the
mouse over a line) and drop in another console or in a X app (with
middle button).

Such confusion of words!!! :) BFN.

musher0
musher0
~~~~~~~~~~
"You want it darker? We kill the flame." (L. Cohen)

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

#25 Post by mavrothal »

greengeek wrote:I want to copy the clipboard into the terminal using the Shift+Ctrl+v shortcut. I have tried the following without success:

Code: Select all

<Key mask="CS" key="v">exec:xdotool key shift+Insert</Key>
The syntax appears right (when I manually enter it into a terminal to see what it does) but it doesn't seem to work when I am working in a terminal, or in geany.
I pointed to the thread but not the jwm-working post (though I did say it needs xsel in addition to xdotool as xclip does not have the -x function, the board exchange)
This being a "copy" thread I just wanted to alert the tread owner in case interested.
== [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
Puppus Dogfellow
Posts: 1667
Joined: Tue 08 Jan 2013, 01:39
Location: nyc

#26 Post by Puppus Dogfellow »

greengeek wrote:Mochi's syntax to copy the terminal selection into the clipboard via Shift+Ctrl+c is as follows:

Code: Select all

<Key mask="CS" key="c">exec:xclip -o|xclip -sel clip</Key>
This works fine on my system. I now also know I can use Shift+Insert to do the opposite - paste the clipboard into the terminal.

I would like to set up a keyboard shortcut similar to Mochi's but the other way around - I want to copy the clipboard into the terminal using the Shift+Ctrl+v shortcut. I have tried the following without success:

Code: Select all

<Key mask="CS" key="v">exec:xdotool key shift+Insert</Key>
The syntax appears right (when I manually enter it into a terminal to see what it does) but it doesn't seem to work when I am working in a terminal, or in geany. I'm very hazy about the difference between primary selection, secondary selection, and clipboard selection - is my syntax failing to select the correct destination buffer before pasting? Am I totally going in the wrong direction?

Also - I notice a slight difference between:

Code: Select all

xdotool key shift+Insert
and

Code: Select all

xdotool key Shift+Insert
The latter syntax (using capital 's') seems to operate twice.

Can anyone suggest a way to activate the shift+ctrl+v shortcut to paste the clipboard into the terminal?

I also tried the following but I'm totally stabbing in the dark here:

Code: Select all

<Key mask="CS" key="v">exec:xclip -i|xclip -sel prim</Key>
have you tried

Code: Select all

<Key mask="CS" key="v">exec:xdotool click 2</Key>
i just highlighted rox /mnt
(plus return)
on this page and entered xdotool click 2 into the terminal and it opened /mnt in rox--may be worth a shot. if it works you could make it a script called called m2 or c2, which may be just as easy.

________

there's also
control-A will take you to the beginning of the line.

control-K will kill the whole line that you have just entered.

control-Y will yank the text back.
from http://askubuntu.com/questions/302263/s ... -the-mouse

yank apparently means paste rather than pull, or at least that's what it does. i guess it's yanking it from a buffer or a memory of having the cursor go over the path of the text--there's no highlighting that i can see, but ctrl+k cuts it, and ctrl+a copies it. short of something like > /root/thiscommand.txt added to the output (i don't know the syntax for print or echo or what else would be needed/better, but ctrl+Home echo Enter after adding > /blah appears to work), i don't see a way to get it off the terminal with the built in options--it's not using the primary or secondary to store what ever it's passing over/munching.

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

#27 Post by MochiMoppel »

Puppus, please...

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

#28 Post by mavrothal »

OK then!
In case you also want to paste, look here
== [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
MochiMoppel
Posts: 2084
Joined: Wed 26 Jan 2011, 09:06
Location: Japan

#29 Post by MochiMoppel »

While the JWM shortcut proposed in the initial post is very simple, here is an even simpler alternative:
Using a desktop icon for shortcut configuration.

Advantages:
  • Not restricted to a particular window manager
  • No need to edit jwmrc-personal
  • No need to restart JWM (hence no screen flicker!)
  • Easy to change and disable
  • Allows code execution with keyboard or mouse
Steps:
1. Create icon as in screenshot (click on "(click to set)" to define shortcut)
2. Select text in console and press Ctrl+Shift+c or click icon to copy
3. Use normal Ctrl+v in to paste the selected text

Notes:
  • Even for users who don't care for desktop icons (me :wink: !), the ease to enable/disable keyboard shortcuts make it an interesting alternative
  • Works also for panel icons. As shortcuts only work as long as the panel is enabled/visible, switching panels allows different shortcut sets
  • JWM and icon shortcuts apply system-wide and can override built-in shortcuts like Ctrl+c or Shift+Ins, so use whith care. If the same shortcut is defined in JWM and in an icon, JWM will prevail.
  • Placing script code directly into the icon (or into jwmrc-personal) is my preference for short code. No scripts lying around, faster execution. Most users will find it easier to create a script. Create a script /usr/bin/mm_copy

    Code: Select all

    #!/bin/sh
    xclip -o|xclip -sel clip 
    Drag the file /usr/bin/mm_copy to the desktop and assign shortcut.
  • Copying console text is only one example to copy stuff to the clipboard which normally can't be copied. Much more interesting is copying file selections in ROX. With a corresponding paste shortcut it is possible to forget drag&drop and use - hold your breath - genuine copy&paste in ROX ... nothing is impossible :lol:
Attachments
Shortcut_via_desktop_icon.png
(20.48 KiB) Downloaded 318 times

Post Reply