11

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!

1
  • 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
    – user35186
    Sep 19, 2012 at 15:06

6 Answers 6

6

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.

5

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
1
  • haven't tried this, but it looks right and answers the question (regarding Clipit)
    – user7610
    Jul 12, 2014 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.

1
1

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('------------------')
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!

2
  • 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. Sep 21, 2012 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... Jan 6, 2013 at 20:15

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .