So I'm using the following script to copy a file line by line into the clipboard:

perl -ne 'm/\t(.+)\n/; open(my $pipe, "|xclip -i"); print {$pipe} $1; close($pipe);'\
         'print; `bash -c "read -p continue"`' photo_captions.txt

In case that's confusing, my photo_captions.txt file contains lines like:

IMG0001.JPG     At the beach
IMG0002.JPG     At the bar

Where the captions are preceded by tabs.

And the script is just capturing everything after the tab to the newline and stuffing it into xclip, printing that to standard out, and then asking the user to press enter to continue to the next line. [the use of bash here is a travesty, or maybe it's perl, either way it mostly works for me].


At the beach
At the bar

What I'd like to do, to make my life a lot easier as I page through photos I've uploaded and paste captions into them, is to pass this whole file to some kind of clipboard manager and have that manager wait for me to paste line one, once pasted, the next paste will be line two, etc, avoiding my need to switch back and press enter to continue. FYI the script without the pause would either copy all the lines as a blob or copy only the last line discarding the previous ones.

Does anyone know of any such program?

I tried the -l option of xclip, and basically my version of xclip doesn't pause or wait correctly; so echo hello|xclip -f -l 1; echo world|xclip -f -l 1; just outputs hello world and only pastes world once not pasting hello. Yet if I add the -verbose flag it does wait, so that works. Except in chrome, it doesn't work in the chrome browser and pastes nothing. So there could be something wrong with xclip or chrome and I'm still wondering if there's another program that does this better.

  • 1
    (not a full answer, just a hint) See a way of interacting with KDE's Klipper using D-Bus: askubuntu.com/a/244236/88802 You can get/set entries, though I'm not sure you're able to modify it on a paste event. – gertvdijk Jul 12 '13 at 9:47

Your Answer

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

Browse other questions tagged or ask your own question.