Git ships with a tiny utility __git_ps1 that displays your current branch in your bash prompt. For Mercurial is a similiar project on Bitbucket available, however it's slow. In fact; it's so slow, you can't work with your shell anymore.
Jannis pointed me to another project called vcprompt which is written in C and currently supports Git and Mercurial. And it's as nearly fast as the __git_ps1 utility. :-)
Steve Losch May 14, 2009
One thing that vcprompt doesn't show, which the other implementations provide, is the dirty state of the repository. The others will display a '?' for "untracked files present", a '!' for "files have been modified", or nothing for a clean repository, which can be really handy.
I'm surprised that the Mercurial PS1 version you linked to on BitBucket is "so slow, you can't work with your shell anymore." I wrote my own version which is even slower than that one (but allows me to split up the pieces by color, see my own blog for details) and I find it very usable. What kind of machine are you running this on?
Martin Mahner May 14, 2009
I agree, the ?! is really handy. I used hg_ps1 with iTerm on OSX. It's really sluggish, every return-hit takes nearly a second to complete, even if I'm not within a hg repository.
Jannis Leidel May 18, 2009
I agree, seeing modification state is very useful. Fortunately vcprompt is far from ready and the author plans to add this feature. In fact I've started implementing Subversion support and found the plumbing for this feature already in place: http://bitbucket.org/jezdez/vcprompt/src/9879f39e4e65/src...
It's "just" a matter of making the vcs backends check for the state and set the appropriate variables.
Jannis Leidel May 28, 2009
Following up my last comment, the support for Subversion revisions has been added in the original repository at http://vc.gerg.ca/hg/vcprompt/.