KDE clipboard on the command line
The attached python script
clip.py makes it easy to use the KDE clipboard on the command line.
For the following examples it is assumed that the script is available in the search path as
gives the content of the clipboard. You can use the switch
-i 2to obtain historic contents, here item number
2, of the clipboard (note that
-i 0refers to the current content).
clip "some text"
"some text"into the clipboard.
ps | clip -
Put the output of some program, here
ps, into the clipboard.
Connect to the server whose hostname is contained in the clipboard.
Use the autocompletion of the shell to copy filenames conveniently to the clipboard.
cat todo | clip -
Copy the content of files, here
todo, to the clipboard.
KDE3 vs. KDE4
As TGarland pointed out in the comments, KDE4 uses dbus instead of dcop. The attached
clip.py file works for KDE4. If you are still using KDE3 (from personal experience: KDE4 is a very worthy update) you can download