7

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.

0

3 Answers 3

7

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.

1
  • +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
    Commented Jun 17, 2011 at 9:07
6

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.

4

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
1
  • 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
    Commented Jun 17, 2011 at 9:11

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .