Hg-Prompt extension for Mercurial

You can add some Mercurial information to your shell prompt, but it can be quite a pain to do this using the commands in Mercurial. Steve Losh created the Hg-Prompt extension purely for the purpose of using it in shell prompts.

To install this extension, first clone the repository somewhere:

$ hg clone https://bitbucket.org/sjl/hg-prompt/

And add the path to the prompt.py in your hgrc file:

prompt = /path/to/hg-prompt/prompt.py

The extension comes with keywords which are listed here. For example, to get the count of incoming changes:

$ hg prompt "{No of incoming changes: {incoming|count}}"

The great thing about this is that if there is no incoming changes, none of the text is printed.

You can easily adapt Hg-Prompt into your shell. For example, in the fish shell, you can print out the incoming changes like this in its fish_prompt.fish:

echo (hg prompt "{No of in changes: {incoming|count}}")

Note: I found Hg-Prompt to be too slow for use as part of command prompt. I switched to VCPrompt.

Tried with: Mercurial 2.8.2 and Ubuntu 14.04

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.