Clipit: copy the entire clipboard

Created on 16 Feb 2012  ·  8Comments  ·  Source: CristianHenzel/ClipIt

a good feature that miss is an option to copy the entire clipboard, all the lines, because the history file is not very usable without a program to parse it (may be you have a script to remove extra characters and parse the file)
i see well a new ctrl alt + key that copy all the lines into a new line. it prevents the use of history file.

Most helpful comment

Having easy access to the history is very useful. Here is a utility I wrote in Python. This works on Ubuntu. On other systems the location of the history file might be different.

#!/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

All 8 comments

Hello,

could you please elaborate the idea? I'm not really sure what you mean, maybe you could also give an example of what _exactly_ you want/need to do, so I can better understand your use-case.

hello ,
i'd like to have an option to copy all the history file. it can be useful if I select many text blocks to be copied into clipit and want to process the copies after.
And the history file is not easy to use for that.
So i see well an option that copy all the history file (and then all the lines) into an new line. we can after paste this line (new copy) and get all the history file (and then all previous copies). an hotkey for this will be even better.

This idea fits also my thinking. I would appreciate a lot this function which I call multiple tastes. It would be nice to be able to copy more than one input and finally, I prefer the output result to be in the following format:

paste 1
empty line
paste 2
empty line
etc.

It's really useful when I read books and try to grab the important lines! Is it possible to do?

This is a feature I miss quite often as well.

Having easy access to the history is very useful. Here is a utility I wrote in Python. This works on Ubuntu. On other systems the location of the history file might be different.

#!/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

Cool, I got this working in command line. How can I use that to directly paste to a running program?

If I understand you correctly, you could pipe the output of cliphist.py into the clipit command (to make it a single history entry), then paste that as usual in the other program.

$ cliphist.py | clipit

@davidsands nice script

i add it in my bashrc :
alias clipit.history='python2 /home/emmanuelux/scripts/cliphist.py'
alias clipit.history.copy='clipit.history | clipit'

Was this page helpful?
0 / 5 - 0 ratings