Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Enable bash tab completion for Mercurial (hg)

I've installed Mercurial (1.4.3-1) on ubuntu and it doesn't do tab completion in bash by default. What is the simplest way to enable this feature?

like image 805
Vincent Scheib Avatar asked Oct 24 '11 20:10

Vincent Scheib


People also ask

How do I enable tab completion?

Just hit Tab while typing a command, option, or file name and the shell environment will automatically complete what you're typing or suggest options to you.

Where do I put bash completion?

Installation. Bash completion will be installed in /usr/local/etc/bash_completion.

Does bash have tab completion?

Bash completion is a functionality through which Bash helps users type their commands more quickly and easily. It does this by presenting possible options when users press the Tab key while typing a command.


1 Answers

You need to

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

You can also enable completion support for all programs:

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

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

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

    This will enable completion for all commands, including Mercurial.

like image 172
Martin Geisler Avatar answered Oct 11 '22 20:10

Martin Geisler