Code Yarns ‍👨‍💻
Tech BlogPersonal Blog

Hg-Prompt extension for Mercurial

📅 2014-May-22 ⬩ ✍️ Ashwin Nanjappa ⬩ 🏷️ fish, hg-prompt, mercurial ⬩ 📚 Archive

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

And add the path to the in your hgrc file:

prompt = /path/to/hg-prompt/

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

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

© 2022 Ashwin Nanjappa • All writing under CC BY-SA license • 🐘📧