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?
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.
curl https://www.mercurial-scm.org/repo/hg/raw-file/tip/contrib/bash_completion -o ~/.hg-completion.bash && source ~/.hg-completion.bash
The mercurial autocomplete script appears to be maintained here:
https://www.mercurial-scm.org/repo/hg/file/tip/contrib/bash_completion
source
this script in your .bashrc
or equivalent
System wide
for all users.
$ sudo curl https://www.mercurial-scm.org/repo/hg/raw-file/tip/contrib/bash_completion -o /etc/bash_completion.d/mercurial
$ source /etc/bash_completion.d/mercurial
The bash_completion script location 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 of
curl http://www.selenic.com/hg/raw-file/tip/contrib/bash_completion -o ~/.hg-completion.bash && source ~/.hg-completion.bash
bash
, curl
(and hg
;-). –
Huntsman source ~/.hg-completion.bash
in your .bashrc
so that you don't have to run this in every new shell. –
Giffy Install bash-completion
package in your Linux (depends on Linux Distribution you are using).
Then go to /etc/bash_completion.d/
and create a file called hg
and put the content of this script (below) into created hg
file.
http://fts.ifac.cnr.it/cgi-bin/dwww/usr/share/doc/bash/completion-contrib/hg
bash-completion
(at least according to the Debian Bullseye repo): github.com/scop/bash-completion .. heres some more info on it: https://mcmap.net/q/519128/-multi-level-bash-completion –
Spurt Since it's neither tagged nor titled "ubuntu", and because googling with fedora also leads here, I'll add a variation on Martin's answer that works by referencing /etc/bash_completion.d/mercurial.sh
instead of /etc/bash_completion
in 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 this works for me on Fedora 11 through 20.
Correction: Fedora 11 and Fedora 20. (Not tested 12-19.)
© 2022 - 2024 — McMap. All rights reserved.