Re: Clipboard in gnome

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Tim here.  X offers two different clipboards by default: the
"selection" buffer and the "clipboard", both of which should be
independent of Gnome vs. KDE vs. whatever.

The "selection" buffer gets populated by selecting text (usually
with the mouse, but also with the keyboard) and gets pasted using
the middle-mouse button.

The "clipboard" is what most Windows/Mac folks would find familiar,
cutting with control+x, copying with control+c, and pasting with
control+v (and many applications have similar Cut/Copy/Paste commands
in their respective Edit menus)

So using control plus X/C/V should work as expected across the vast
majority of applications.

I run a program called "clipit" that sits in my system tray (I
predominatly interact with it via keyboard shortcuts, almost never
by clicking on it) that keeps a history of the last N clipboard
contents, and can help synchronize the selection vs. clipboard
contents.

Additionally, you can use programs like xclip or xsel to access the
clipboard on the command-line similar to pbcopy/pbpaste on the Mac.
So you can put a text file on the clipboard with

  $ xsel -ib < my_file.txt

or put the output of some command into the clipboard

  $ ps | xsel -ib

or grep the clipboard contents for some pattern:

  $ xsel -ob | grep "pattern"

You can even chain them so you can use sed to process your clipboard
contents like

  $ xsel -ob | sed 's/old/new/g' | xsel -ib

Or use awk to sum the list of numbers in the clipboard, and append
that sum to the clipboard contents:

  $ xsel -ob | awk '{t+=$1}END{print t}1' | xsel -ib

I have a shell function to strip out the utm_* tracking parameters
from URLs that uses this trick:

  utm () 
  { 
    xsel -ob | sed 's/&*\<utm_[^&]*//g;s/[&?]*$//' | xsel -ib
  }

That lets me copy a URL to the clipboard, run "utm" and the URL in
the clipboard has all the UTM tracking bits removed.

For context, the "-i" means that xsel should populate the clipboard
(take it as *in*put) and the "-o" means that xsel should dump the
contents of the clipboard on standard-out (provide *out*put).  The
"b" option says to use the "clipboard" buffer rather than the
"selection" buffer.

I don't use xclip as much, but it has similar options.

Hopefully this gives you some tools to make your life easier.

-tim



On 2023-02-10 11:10, Linux for blind general discussion wrote:
> Most of my unix stuff I've been doing for 34 years is in an ASCII
> text command terminal, no GUI so I am in unfamiliar waters, here,
> even though I have tried tidbits of orca and gnome on occasion
> for a number of years but always got shot down by running it on
> systems with not enough horsepower to run X-windows without
> crashing.
> 
> 	I now have a HP PC running bullseye that has quite enough
> resources so am using that also these days but I am most familiar
> with the Windows GUI and nvda and use the clipboard all the time
> there.
> 
> 	So, my question here is whether there is an orca
> clipboard.  I did do 
> 
> apropos clipboard 
> 
> and saw a reference to TK::ClipBoard which is a perl module and
> xclipboard which is an application.
> 
> 	Is there a clipboard native to gnome or orca?  Also
> acceptable is some application I can install that produces a
> clipboard in gnome.
> 
> 	Clipboards are fabulous things when one has a huge url or
> shell command with gobs of tricky syntax where one misplaced
> space can blow things up.
> 
> 	It's nice to see there is a perl module for clipboard but
> right this minute, I would be happy with a clipboard similar to
> the one in Windows or pbcopy which lives in MacOS.
> 
> 	Thank you.
> 
> Martin McCormick	WB5AGZ
> 
> _______________________________________________
> Blinux-list mailing list
> Blinux-list@xxxxxxxxxx
> https://listman.redhat.com/mailman/listinfo/blinux-list
> 

_______________________________________________
Blinux-list mailing list
Blinux-list@xxxxxxxxxx
https://listman.redhat.com/mailman/listinfo/blinux-list




[Index of Archives]     [Linux Speakup]     [Fedora]     [Linux Kernel]     [Yosemite News]     [Big List of Linux Books]