michael-mccracken.net

Linking the OS X Clipboard and XTerm’s selection

If you only use X11 for XTerm, it might seem like the handling of the clipboard in Apple’s X11.app is broken. You can select text and paste it with a click of the middle mouse button (opt-click on my Powerbook), and that works when pasting into other X apps, but it doesn’t change the Mac clipboard at all.

Why not? Is X11.app just ignoring the X clipboard?

No - X11.app does synchronize the two clipboards. The problem is that the selection pasting in XTerm is using a completely different buffer. There’s a full and clear explanation, with some interesting details about (X)Emacs’ behavior, at jwz.org.

If, like me, you only use X11 for Emacs and XTerm, you might want to link the selection in XTerm to the X clipboard, so X11.app will then sync that with the system clipboard and you can select in XTerm and paste with Cmd-P in say, Mail.app.

I’ll tell you how in a sec, but first the caveat - I said if you only use X11 for Emacs and XTerm because what we’re going to do is make setting the XTerm selection always overwrite the clipboard contents. If you use X apps that use the X clipboard, sometimes you don’t want that. So beware. If you use Emacs, it just pushes onto the kill ring, so you’re good.

OK, now that that’s over, add these lines to your ~/.Xdefaults:

XTerm*VT100.Translations: #override\
<BtnUp>: select-end(CLIPBOARD,PRIMARY)\n\
<Btn2Down>: insert-selection(PRIMARY)\n\

Note that the backslashes at the end of the lines are important.

Update: The first version of this post didn’t include the Btn2Down action. Without that, the original paste behavior goes away - the man page doesn’t really explain the “#override” keyword, so I’m not sure why.

Previously:
Mac programming collaborative bookmarks?
February 7, 2007

I usually like the link selection I get from the Joel Reddit, which usually has good software-related essays at the top. It seems to avoid links to uninformed rants about consumer electronics or industry politics, for which I have no use.

I’d like a social links site for software professionals on the Mac - does one [...]

read the rest.
Quick n’ Dirty OmniOutliner to MediaWiki Applescript
January 30, 2007

The other day, I had a big outline on a wiki that I wanted to edit in OmniOutliner so I could hide and move things around with a real outliner, then export it back out to the wiki.

I managed to get it into OO with copy and paste and a lot of RSI-inducing tabbing, but [...]

read the rest.
Take Control of OS X Backups

The excellent “Take Control” series of Mac ebooks has updated “Take Control of OS X Backups” to version 2.0.

I have gotten a lot of use out of their other books. “Take Control of Your Airport Network” saved me a lot of frustration setting up a network for my roommates, and “Take Control of [...]

read the rest.
« Previous PageNext Page »
Feed, Endorsements & other Links

my bookmarks

© 2005 - 2007 Michael McCracken.