The :; shell prompt trick

March 2, 2006

For years, I've had a somewhat unusual shell prompt. It looks like this:

: <host> ;

(where <host> is the hostname of the current machine.)

Putting the hostname in your prompt is pretty ordinary, but what's the other stuff? These days, a more typical shell prompt is something like 'cks@newman:~$ ', to quote a Debian example. (And many people use more elaborate prompts, such as Jamie Zawinksi's.)

The trick here is that the : and ; turn my prompt into a valid shell command that does nothing. This makes cutting and pasting previous commands in things like xterm much easier, since I don't have to carefully get just the command while avoiding the prompt. (In xterm it's just a quick triple click, but then xterm is very good at this.)

(In practice I am sufficiently neurotically neat that I select just the command, because seeing a doubled prompt looks wrong. This might be different if my prompt was just ':; ', but I need the host name in it to keep things straight.)

This trick is not original to me; I believe I got it from observing Geoff Collyer, many years ago.

Sidebar: xterm's double-click selections

One reason I don't use this more is that xterm's double-click selection mode makes selecting most things pretty fast anyways. For those who aren't aware of it, when you start a selection by double-clicking instead of single-clicking, xterm grows the selection by words instead of characters. (Try it; it's more intuitive than I make it sound.)

Embarrassingly, I spent years using xterm before I found out about this. Now I use it all the time, and hardly ever have to select by characters.

Written on 02 March 2006.
« Unicode is not simple
A robots.txt surprise »

Page tools: View Source, Add Comment.
Search:
Login: Password:
Atom Syndication: Recent Comments.

Last modified: Thu Mar 2 02:47:41 2006
This dinky wiki is brought to you by the Insane Hackers Guild, Python sub-branch.