clipboard

a utility by the Bored Zo


What it is

clipboard is a command-line tool for getting and setting the clipboard. simple sample uses:

getting
clipboard -v foo.txt (pastes into file 'foo.txt')
setting
echo -n foo | clipboard (copies 'foo' to the clipboard)
clipboard -c foo.txt (copies the contents of file 'foo.txt' to the clipboard)

Requirements


Files

1.0
1.0.1
2.0

Version History

1.0
  • initial release.
1.0.1
  • added newline translation.
2.0rc1
  • added command-line arguments. see the full manual for details. the most important arguments are -c (copy), -v (paste), and -b (clear).
  • clipboard is now smarter about figuring out where it is in the pipeline when you invoke it with no arguments. no more false positives (yea!).
  • added support for reading directly from regular files. specify the filename on the command-line. for best results, specify one of the subcommand arguments as well.
2.0rc2
  • fixed a fatal addressing error in copy_bufs (note to self: --i, not i--).
2.0rc3
  • fixed an annoying bug in which you got the implicit paste even when requesting an explicit paste (due to implicitpaste defaulting to Yes instead of Maybe).
  • changed conditionals from e.g. ifdef ARGSUPPORT to ifndef NOARGSUPPORT (makes compilation simpler).
2.0rc4
  • fixed a rather silly bug wherein versions were printed as e.g. '2rc2' instead of '2.0rc2' (format was %.0f rather than %.1f).
2.0rc5
  • eliminated a redundant realloc.
  • added support for 'escalating' allocation (see below).
  • added a 'trim' realloc to readfile (stdin section) to eliminate waste (chiefly when escalation has been compiled in) and maybe speed the program up on large data.
  • added build manifest to --version.
2.0rc6
  • file-descriptor I/O. (compile with -DUSE_FD in the build command, after the version identifier.)
  • added file locking. should be safer against operations by other processes.
2.0rc7
  • argument parser is now much smarter. for one thing, you can now do 'clipboard <filename>' and it will figure you meant 'clipboard -c <filename>'.
  • tightened up a switch in the argument parser - '-e' is no longer separate from '-v' and '-r'. no effect in the optimised builds, but debug builds should be slightly smaller.
  • implicit pastes work properly now.
  • the build script now uses mkdir -p to avoid errors on Mac OS X systems that don't have a /usr/local/bin (I've read that these do exist).
2.0rc8
  • changelog in top comment again (woops)
  • no-argsupport builds should be smaller (help and version functions are no longer compiled into those)
  • -s bufsize switch works properly now
  • no longer writes implicit newline after paste when the output file is not a tty
  • toclip emulation is now optional (define TOCLIPSUPPORT in the preprocessor to get it)
  • help strings now properly morph when invoked as toclip (when toclip emulation is built)
2.0
  • now using mmap to 'read' regular files
  • translatenewlines uses a translation table or switch instead of if-else-if
  • assorted hole-plugs
  • buildit is smarter about dealing with permissions WRT /usr/local/bin
  • buildit can use install destinations other than /usr/local/bin
  • buildit detects the absence of False and True (indicates Python 2.2.0) and compensates

Credits

Landon Fuller
for pointing out fcntl to me

15 April 2004 http://boredzo.org./clipboard/
Valid HTML 4.01!