Mercurial Shell Completion: Boost Your Command Line Efficiency

The cursor blinks. You type hg and your shell already knows what you want. That is Mercurial shell completion at its best—fast, precise, invisible until you need it.

Mercurial shell completion speeds up workflows by auto-suggesting commands, options, and branch names. It reduces keystrokes and minimizes errors. This feature integrates directly with Bash, Zsh, or Fish, so you can tab through the Mercurial CLI without consulting documentation. Enabling it takes minutes, but the performance gain lasts for years.

To enable Mercurial shell completion in Bash, add this to your .bashrc or .bash_profile:

source /path/to/mercurial/contrib/bash_completion

For Zsh, use:

autoload -U compinit && compinit
source /path/to/mercurial/contrib/zsh_completion

In Fish:

source /path/to/mercurial/contrib/fish_completion.fish

Make sure you have the completion scripts from the Mercurial source distribution. Once sourced, reload your shell and test with hg <TAB>. You should see commands like commit, update, and merge appear instantly. Branch listings and file paths will populate automatically, keeping your command line tight and efficient.

Mercurial shell completion works with aliases, custom commands, and extensions. If you use hooks or advanced workflows, completion scripts adapt, giving you contextual suggestions. For large repositories, these scripts can save seconds on every interaction. Over days of coding, that becomes hours.

No IDE plugin beats the immediacy of well-tuned shell completion. It’s local, it’s lightweight, and it’s always in sync with your repository state. Engineers who work across multiple projects will see a direct speed boost, especially when switching branches or running complex merge commands.

Stop guessing commands. Stop repeating keystrokes. Source the right script and let Mercurial shell completion carry the load.

Want to see how this feels with a modern DevOps workflow? Try it in hoop.dev—spin up a repo and watch completion work in minutes.