Linux – Copying clipboard-content to file automatically and continiously

clipboardlinux-minttext;

I need to make a list of some links on a web-page. I've been using right-click copy link URL and then pasting it (Menu_Edit->Paste) into vim running in xterm — then repeating. This is obviously a rather cumbersome approach, and surely there must be a better way. (The pasting goes fine, so I guess the links are stored as ascii-text.)

So is there a way to automatically "record" each copy link URL (onto the clipboard) to a file – Ie. copying each change in the clipboard to a file? Is there a program that can do this, or perhaps some hidden file (eg. a named pipe) from which I could read the clipboard content?

I see there are some "clipboard managers"… are any of them suited to do something like this? (which one? how?)

I'm using LinuxMint MATE.

Best Answer

You could do something like:

while xclip -o -sel c && echo; do
  xclip -i -quiet -sel c <> /dev/null >&0 2>&0
done > file

xclip -o -sel c dumps the content of the CLIPBOARD selection. xclip -i -quiet -sel c claims ownership of the CLIPBOARD selection (and makes it empty) until something else claims it again. If you have a clipboard manager running, you may want to disable it as it would probably interfere.

Related Question