I often find myself in the situation that on my web browser, I have a bunch of open tabs all with things I would like to have a look later but when I find the time, all these open tabs are not on the device I'm currently using or want to use, e.g., due to form factor (laptop vs desktop vs different laptop, etc). The work environment on all those devices essentially is the same, thanks to the home manger, but open tabs stay on their device. Moreover, this not only happens for URLs but also for other kinds of short strings. So I wanted to solve the synchronization problem independent of the browser use case and have something like a shared collection of clipboard entries.
The standard approach for synchronizing files between machines is, of course, version control. That solves all the heavy lifting like access to remote machines, including delegation of authentication, conflict detection, etc. Of course, it is not really necessary to store the history of inter-machine clipboard entries, but what amount of data are we actually talking about? Say 80 bytes for an entry, at most 10 entries a day, that's less than a kB per day, in other words, one MB in about than 3 years. Should be manageable. And if we use cvs as version control system, we can also use rcs -o to censor out part of the history, e.g., for privacy reasons. So, let's do it the easy way and build the whole thing on version control.
So, basically we have to manipulate a versioned file. That means, knowing how to call update and commit for that file, as well as changing its content. So what should the content be? We keep a bunch of clipboard entries; to allow easy specification of which entry to use, make it a list. Each entry could be a single string, but we actually get the nicer interaction on the command line if we take what is naturally given at the command line, i.e., a list of strings. So a list of lists of strings it is. To avoid issues with quoting, we use a standard format that is well supported with libraries, say JSON. While not directly read by humans, we still store it pretty-printed; that gives small line-based diffs. As rcs (which is the actual data structure used by cvs) stores for each revision an asymmetric line-based diff describing how to get it from the previous, small line-based diffs save space in the repository.
The rest is a small coding exercise. So here we have