Quote:
Originally Posted by vpa2013
Anyone knows a way to have this "copy to main clipboard on select in terminal" feature working but only for the terminal and not for all the selections to avoid the overwrite scenario issues, it would be great to share because this keeps bugging me every day!
|
The selection-copy mechanism is a function built into the x-server, not the programs. And it's not even a "buffer" as such, but a data transfer. When you middle-click, the x-server directly copies the currently (or most recently) highlighted text data from the source process into the target process. That's why you can't paste data after closing a window, by the way, as there's no buffer to store the text in. When the program vanishes, so does the selection.
The separate "clipboard" was designed to be a less ephemeral alternative with a real, live buffer. You use it when you need to store the text temporarily while you do something else. The clipboard is there to do exactly the kind of thing you're asking for.
And yes, terminal applications can be a hassle when it comes to the clipboard cut+paste, due to the pre-existing definition of ctrl+c as SIGINT that likely pre-dates the modern gui. But most console applications do define alternative shortcuts for it. Konsole, for example, predefines shift+insert for pasting from clipboard, and ctrl+shift+insert for pasting from selection. Check the keybindings of the program you're using.
It's also possible to use stty to re-define the key combo that sends the SIGINT signal to the terminal. I've never tried doing it myself though, so look it up.
I suggest though that what you really need to do is readjust your thinking to adapt to the x-windows paradigm. Having two separate features that work slightly differently is actually more convenient, IMO, than trying to unify them with a synchronizing tool. So learn to prepare the target area
before you select. Fall back to using the clipboard when that isn't possible, and be aware that different programs may have different ways to call the paste function.
For Firefox, use extensions like
xclear, or one of several others that provide toolbar buttons for clearing fields. Some other programs like konqueror also provide clear-field buttons precisely for this purpose.
Another thing you can do is set up a couple of simple scripts (using xsel or xclip) to manually transfer text between the selection and the clipboard. Add a couple of toolbar launchers/shortcuts/mouse gestures/whatever to execute them, and you have a quick way to save selected text to the clipboard, then back again to the selection for pasting.
Code:
#!/bin/bash
# seltoclip -- copy the current highlighted
# selection to the clipboard.
xsel -o | xsel -i -b
Code:
#!/bin/bash
# cliptosel -- copy the current
# clipboard text to the x-selection.
xsel -o -b | xsel -i