KDE clipboard on the command line
Date: Jul 24, 2010
The attached python script clip.py makes it easy to use the KDE clipboard on the command line.
Basic usage
For the following examples it is assumed that the script is available in the search path as clip.
-
clip
gives the content of the clipboard. You can use the switch-i 2to obtain historic contents, here item number2, of the clipboard (note that-i 0refers to the current content). -
clip "some text"
Put"some text"into the clipboard. -
ps | clip -
Put the output of some program, hereps, into the clipboard.
Some examples
-
ssh $(clip)
Connect to the server whose hostname is contained in the clipboard. -
clip long_file_name
Use the autocompletion of the shell to copy filenames conveniently to the clipboard. -
cat todo | clip -
Copy the content of files, heretodo, 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 clip3.py.
Comments
KDE4 uses dbus instead of dcop. A similar script which utilizes dbus can be found here:
http://milianw.de/code-snippets/access-klipper-clipboard-on-cli-under-kde4
Thanks for the comment and the link! After a one line change of code the script now works for KDE4.
Post new comment