Getting clickable URLs in xterm (sort of)
My terminal emulator of choice is xterm: it's fast, light, and (since it's pretty much the reference implementation) it has excellent support for everything a console user could desire... except for one thing that would be very, very convenient: making URLs clickable. Other terminal emulators have this feature, but they also have problems that make them inferior to xterm in different ways.
Over the years people have come up with various workarounds for this situation, like screen scraping utilities (urlview, urlscan) that can be hooked up to other console programs to extract and browse URLs, but they're still not as convenient as just using the mouse, and often require the program to run on the same machine as the browser.
Fortunately, xterm #277 (released in January 2012) added a new
feature that provides almost exactly what I had been looking for: it can
now spawn programs using the exec-formatted action and give them as
argument the contents of the current selection or clipboard. So you can
add the following to your ~/.Xresources:
*VT100*translations: #override Meta <Btn1Up>: exec-formatted("x-www-browser '%t'", PRIMARY)
which makes xterm run x-www-browser on the selection when it receives
Alt + left click. (Adjust for whatever your Meta key is.)
This is advantageously combined with a charClass setting to make xterm
treat URLs as a single word, so that you can just double-click on them
to select them:
XTerm*charClass: 33:48,36-47:48,58-59:48,61:48,63-64:48,95:48,126:48
With both of these enabled, opening URLs is now just a matter of:
- Double-clicking the URL to select it
- Doing Alt + click anywhere on the xterm window to run the browser
which, while more involved than a single click, it still much faster than having to copy the URL manually to the browser.
RSS