Enable bash tab completion for Mercurial (hg)

I installed Mercurial (1.4.3-1) on ubuntu and by default does not complete tab completion in bash. What is the easiest way to enable this feature?

+7
source share
5 answers

You need

  • Install an updated package for Mercurial, see Mercurial PPA . This will give you the /etc/bash_completion.d/mercurial file with the completion code for Mercurial. You can directly download this file to enable Mercurial support.

You can also enable termination support for all programs:

  • Install the bash-completion package: aptitude install bash-completion .

  • Source /etc/bash_completion in your ~/.bashrc :

     # Use bash-completion, if available if [ -f /etc/bash_completion ]; then . /etc/bash_completion fi 

    This will complete execution for all commands, including Mercurial.

+12
source

Install the bash -completion package on your Linux (depending on the Linux distribution used).

Then go to / etc / bash_completion.d / and create the hg file

and put the contents of this script (below) into the created hg file

http://fts.ifac.cnr.it/cgi-bin/dwww/usr/share/doc/bash/completion-contrib/hg

+2
source
 curl https://www.mercurial-scm.org/repo/hg/file/tip/contrib/bash_completion -o ~/.hg-completion.bash && source ~/.hg-completion.bash 

This stores the contents of the mercury autocomplete script:

https://www.mercurial-scm.org/repo/hg/file/tip/contrib/bash_completion

source this script in .bashrc or equivalent

+2
source

The location of the bash_completion script has changed, so you need to do

 curl https://www.mercurial-scm.org/repo/hg/raw-file/tip/contrib/bash_completion -o ~/.hg-completion.bash && source ~/.hg-completion.bash 

instead

 curl http://www.selenic.com/hg/raw-file/tip/contrib/bash_completion -o ~/.hg-completion.bash && source ~/.hg-completion.bash 
+2
source

Since it is not marked or named "ubuntu", and also because googling with fedora is included here, I will add Martin's answer option, which works by referring to /etc/bash_completion.d/mercurial.sh instead of /etc/bash_completion to your ~/.bashrc :

# Use bash-completion, if available if [ -f /etc/bash_completion.d/mercurial.sh ]; then . /etc/bash_completion.d/mercurial.sh fi

Not sure if the OS makes this distinction necessary, but it works for me on Fedora 11 to 20.

Fix: Fedora 11 and Fedora 20. (Not tested 12-19.)

0
source

All Articles