A command-line clipboard copy and paste utility?
In Windows I used command-line clipboard copy-and-paste utilities...
-
pclip.exe
andgclip.exe
These were UnixUtils ports for Windows (but they only handled plain text). There were a couple of other native Windows utilities which could write/extract any format.
I've looked for something similar in Synaptic Package Manager, but I can't find anything.
Is there something there, that I've missed? ... or maybe this is available in Bash scripting?
The type of utility I'd like will be able to read/write via std-in/std-out or file-in/file-out, and handle Unicode, Rich Text Format, picture, etc. clipboard formats...
NB: I'm not after a clipboard manager.
xsel
I am using xsel Install xsel, but I am only using it with plain text and unicode text.
xsel
can copy and paste to three different "clipboards".
By default, it uses the X Window System primary selection, which is basically whatever is currently in selection. The X Window System also has a secondary selection (which isn't used much), and a clipboard selection. You're probably looking for the clipboard selection, since that's what the desktop environment (e.g. Gnome, KDE, XFCE) uses for its clipboard. To use that with xsel:
xsel --clipboard < new-clipboard-contents.txt
xsel --clipboard > current-clipboard-contents.txt
xclip
Install xclip may be one of your choices.
cat samples.sh | xclip -sel clip
you can also setting it in the .bashrc file using alias.
alias clipboard='xclip -sel clip'
The key to paste binary data to a file with xclip
is to tell what Media Types you have on clipboard. For PNG you can:
xclip -selection clipboard -t image/png -o > "`date '+%Y-%m-%d_%T'`.png"
So now on ~/Dropbox/.mybashrc
;) you can add an alias (clipboard2photo) to easily paste to image file (maybe someday we'll have it on Nautilus).
Parcellite
I've used parcellite for many years as a clipboard manager. It runs in the Notification Area and offers many options for managing both Primary Selection and standard freedesktop.org Clipboard.
It's been my answer to managing clipboard items.
I recently came across the tools xclip-copyfile
, xclip-cutfile
, and xclip-pastefile
(package xclip
). These tools allow you to copy/cut/paste entire files via the command line.
You can see their man page here.
clipit
clipit is a clipboard manager for GTK+ that allows piping text from the command line:
ls | clipit