Wed, 08/13/2008 - 23:12
NOTE: find most recent version on github: https://github.com/milianw/shell-helpers/blob/master/clipboard
Here’s a little script you can save in your path and do things like
- # paste current clipboard into file
- clipboard > "some_file"
- # copy some file into clipboard
- cat "some_file" | clipboard
Actually I find it rather useful so I thought I should share it.
- # Access your KDE 4 klipper on the command line
- # usage:
- # ./clipboard
- # will output current contents of klipper
- # echo "foobar" | ./clipboard
- # will put "foobar" into your clipboard/klipper
- # check for stdin
- if ! tty -s && stdin=$(</dev/stdin) && [[ "$stdin" ]]; then
- # get the rest of stdin
- # oh, nice - user input! we set that as current
- # clipboard content
- qdbus org.kde.klipper /klipper setClipboardContents "$stdin"
- # if we reach this point no user input was given and we
- # print out the current contents of the clipboard
- qdbus org.kde.klipper /klipper getClipboardContents
As usually, save the file (attached below) in your
$PATH and make it executable.