2009-11-25

Even easier copy and paste for X11 in Snow Leopard

A week ago, I blogged as a result of rather long-standing frustration.

I didn't think my solution through properly. This can be solved in a far superior manner with a FIFO (pipe).

Here's how to do it with just one xterm and one Terminal.app window/tab dedicated for the purpose.

  1. mkfifo ~/tmp/paste

  2. In Terminal.app: cat ~/tmp/paste - leave this running

  3. In the xterm: cat > ~/tmp/paste - leave this running

  4. Paste whatever you want into the xterm that's redirecting its output to ~/tmp/paste.

  5. This text automagically appears in the Terminal.app window/tab. Copy it from there and into the application you wanted to provide it to in the first place.

2009-11-18

Copy and paste from X11 in MacOS X Snow Leopard

Apple has done it again: broken something beyond repair.

In Snow Leopard, copy and paste between X11 and other applications seems at first to work just as in previous versions of MacOS X.

But after a while, it just stops working.

To "fix" it, you need to quit the X11 application and start over.

But that also means exiting all the X11 client applications that you had running, it's not quite as simple as restarting a window manager used to be.

Apple is notorious for not fixing bugs with their X11 implementation other than at the time of a new MacOS X version, so don't hold your breath.

So here's a butt-ugly work-around. Prerequisite: a spare xterm with e.g. bash running.
  1. Select the text you want to copy.

  2. Copy it into your spare xterm. Example: copying the URL http://www.google.com/ (in real life, the URL is bound to be harder to type by hand)
    jani@computer ~ >echo 'http://www.google.com/' > /tmp/paste

  3. Switch to a first-class Mac application citizen, like Terminal.app.

  4. In Terminal.app, get the contents of the paste file:
    jani@computer ~ >cat /tmp/paste
    http://www.google.com/

  5. Select the text and copy it with command+c

  6. Switch to your favourite browser, e.g. Opera

  7. Paste the URL into the address bar


See, that was eaaaasy.

*grumble*