1. pbcopy and pbpaste

    The Unix command line has historically interacted poorly with the numerous graphical interfaces that have been stacked upon it. One key area lacking support is the clipboard. MacOS X brings two utilities to close that gap, pbcopy and pbpaste. These commands together provide complete access to the MacOS X clipboard (which Apple calls the pasteboard, explaining the names of these two commands).

    The first of the two, pbcopy, takes its input from the standard input and adds it to the system clipboard. The command only accepts one option, -pboard, which accepts one of four suboptions, “general”, “ruler”, “find”, and “font”, all of which are different system clipboards available on MacOS X. The general pasteboard is the main system clipboard and the others are for special use.

    The pbpaste pulls data from the clipboard and prints it to the standard output. Like pbcopy, pbpaste accepts the option -pboard to determine which pastebaord to acquire data from. The pbpaste command adds a second option, -Prefer which takes three possible options “txt”, “rtf”, and “ps”. These options direct \cmd{pbpaste} looks for a certain type of formated information on the pbasteboard. The “txt” flag suggests standard text data. The “rtf” and “ps” suggest Rich Text Format and PostScript, respectively. Despite this option, it is not possible to direct the exact output pbpaste prints. This option only tells pbpaste what type of information to return first.

    These two commands offer the MacOS X command line warrior a simple and fairly complete set of tools for working with and manipulating the MacOS X pasteboards.

  2. More Old Code at GitHub

    I have recovered from an old Iomega Zip disk a few more programs I wrote in the 1997-1998 time frame which may be of some interest:

    • daemon
      Daemon was originally written for FreeBSD to use the 4.4BSD library function, daemon(3) to launch a command after disassociating itself from the controlling TTY.  I originally saw such an application on M-Net which ran BSD/OS 3.1 at the time.  The source was unavailable, but it was easy to reimplement.  Modern Linux implementations now include daemon(3), so it should be usable on Linux today.

    • rpt
      Rpt was based upon the source from daemon, above but instead of disassociating from the controlling terminal, rpt reruns the command at a specified interval.  This allows the user to monitor the output of a program over time.

    • uwatch
      Uwatch was also born of M-Net.  M-Net is an interactive BBS system dating back to 1983, which has always allowed users to communicate directly in real time.  As a result, someone once developed a program to notify users when their friends logged in or out.  However, it was always spotty at best, especially during a long session.  I worked extensively on it back in 1997 to solve some memory management issues.  This is what remains of that effort.

    • write
      When I was a student at Miami University, we had several Linux systems spread across three (of four) campuses and we occasionally used write(1) to talk to each other.  This implementation of write honors MIT’s Project Athena’s network-aware write protocol and allows users to send message to users on other systems.