Bash – Tab-completion for Mercurial in Bash

autocompletebashmercurial

Using Subversion on the command-line, it intelligently tab-completes available subcommands, etc:

$ svn c<tab>
cat         checkout    cl          co          copy        
changelist  ci          cleanup     commit      cp  

Mercurial, on the other hand, doesn't seem to have tab-completion, at least out of the box:

$ hg c<tab> 
[nothing happens]

Is Bash completion for Mercurial available at all? What's the simplest way to get it working? I'm on Ubuntu 11.04.

Best Answer

In Ubuntu 10.04 it works out of the box for me. In bash:

$ hg c
cat       checkout  clone     commit    copy

Or in zsh:

$ hg c
cat       checkout  ci        clone     co        commit    copy      cp

Perhaps you have a package missing (or you hit a bug).

On my system the completion file is provided by the mercurial package:

$ dpkg -S /etc/bash_completion.d/mercurial 
mercurial: /etc/bash_completion.d/mercurial
Related Question