Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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.

share|improve this question
up vote 4 down vote accepted

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
share|improve this answer
Thanks - the reason it wasn't working for me was that I had just installed the "mercurial" package and bashrc hadn't been re-read! So e.g. opening a new terminal tab or just typing bash got it working. Well, I'm glad it works without any extra tweaking needed. :) – Jonik Jun 17 '11 at 9:11

Mercurial ships it's own bash completion - see contrib/bash_completion in the tarball. At least on openSUSE, this file is installed to /etc/bash_completion.d/, so that bash completion for mercurial is working automatically. You might need to check Ubuntu's mercurial package, if it installs the completion script.

share|improve this answer
+1, the file /etc/bash_completion.d/mercurial seems to be available indeed in the "mercurial" package on Ubuntu too. See my comment to maxschlepzig's answer... – Jonik Jun 17 '11 at 9:07

I built mercurial from a source release and had to install the completion script myself. This is how to do this:

$ cd
$ wget http://selenic.com/hg/raw-file/25e4d2f35965/contrib/bash_completion -P opt/packages/mercurial
$ echo ". opt/packages/mercurial/bash_completion" >> .bashrc
$ . opt/packages/mercurial/bash_completion

Completion is ON.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.