10

I would like to paste my whole clipboard history consisting of words copied (Ctrl+C/by selection) during my reading sessions. I installed programs like Glippy and ClipIt but I couldn't figure out how to paste all the words, if ever exists such an option in these programs, I copy to a simple text file at once, not one word at a time. Can someone help me out?

Thank you!

  • clipit stores its history in ~/.local/share/clipit/history, the format has some control characters, you can probably parse them out with sed, but that's a bit complicated – bartekbrak Sep 19 '12 at 15:06
4

You can see some strings in clipit history file with this command:

strings ~/.local/share/clipit/history

But it's not the best way. The output may be garbled.

3

there is python script for ClipIt run it like this python cliphist.py > clipit.history.txt

#!/usr/bin/env python
"""cliphist.py: utility to print clipit history file.
If an argument is passed on the command line, it will
be used as a separator, otherwise history items are
separated by a blank line. """

import struct, os, sys

homedir  = os.environ['HOME']
histfile = homedir + '/.local/share/clipit/history'
if len(sys.argv) > 1:
    sep = sys.argv[1]
else:
    sep = '---------------------------------------------------------------------'


with open(histfile,'rb') as f:
    f.read(68)
    size,_ = struct.unpack('2i',f.read(8))
    while (size > 0):
        item = f.read(size)
        print item
        _,_,_,size,_ = struct.unpack('5i',f.read(20))
        if size > 0: 
            print sep
  • haven't tried this, but it looks right and answers the question (regarding Clipit) – user7610 Jul 12 '14 at 15:16
2

The latest version of Parcellite has a Save As menu item when clicking the icon. This will save all the history entries to a file. There is also a paste all when right-clicking the history list, which will place the entire history list on the clipboard. The preferences have a Paste All delimiter that it will put at the end of each entry.

https://sourceforge.net/projects/parcellite/files/parcellite/parcellite-1.1.1/ ppa here: https://launchpad.net/~rickyrockrat/+archive/ppa

1

Install KDE's Klipper Clipboard Manager Install klipper and use the following simple script:

text="nothing yet"
cnt=0
while [ "$text" != "" ]; do
  text=`qdbus org.kde.klipper /klipper getClipboardHistoryItem $cnt`
  echo "==== Clipboard content line $cnt:"
  echo "$text"                      # to terminal output
  echo "$text" > /path/to/file      # to file (EDIT this)
  cnt=$((cnt + 1))
done

Note: This does not behave very well in Unity so it seems. So in other desktop environments than KDE: your mileage may vary.

0

user Parcellite, left click on its icon, "clear", select how many times you want, after that, "edit clipboard" and copy it all! Remember so set preference: use primary selection, to make it easier to copy the text!

  • Hi Acquarius! Thank you so much for the reply. However, when I click edit clipboard I only see the last word I copied and not the whole list. Maybe with you it works another way? Maybe I must configure something in the preferences. – pandisvezia Sep 21 '12 at 17:14
  • there is this file ~/.local/share/parcellite/history, the problem is it has non printable characters to newline and such.. you may try autoReplacing/erasing them but now this starts to get messy... – Aquarius Power Jan 6 '13 at 20:15
0

Modified code from @stepan-shamaiev for Python 3 and without setting of separator:

#!/usr/bin/env python3
"""cliphist.py: utility to print clipit history file."""

import struct, os

homedir  = os.environ['HOME']
histfile = homedir + '/.local/share/clipit/history'

with open(histfile,'rb') as f:
  f.read(68)
  size, _ = struct.unpack('2i', f.read(8))
  while size > 0:
    item = f.read(size)
    print(item.decode())
    _,_,_,size,_ = struct.unpack('5i',f.read(20))
    if size > 0: 
      print('------------------')

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.