为 Mercurial (hg) 启用 bash Tab 补全
我已经在 ubuntu 上安装了 Mercurial (1.4.3-1),默认情况下它不会在 bash 中完成制表符补全。启用此功能的最简单方法是什么?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(6)
您需要
/etc/bash_completion.d/mercurial
文件,其中包含 Mercurial 的完成代码。您可以直接获取此文件以启用 Mercurial 的完成支持。您还可以为所有程序启用完成支持:
安装
bash-completion
软件包:aptitude install bash-completion
。在
~/.bashrc
文件中源/etc/bash_completion
:这将为所有命令启用补全,包括 Mercurial。
You need to
/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:This will enable completion for all commands, including Mercurial.
Mercurial 自动完成脚本似乎保留在此处:
https:// www.mercurial-scm.org/repo/hg/file/tip/contrib/bash_completion
source
此脚本位于您的.bashrc
或同等水平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.
bash_completion 脚本位置已更改,因此您需要执行
以下操作
The bash_completion script location has changed so you need to do
instead of
由于它既没有标记也没有标题“ubuntu”,并且因为用 fedora 进行谷歌搜索也可以找到这里,所以我将在 Martin 的答案上添加一个变体,通过引用
/etc/bash_completion.d/mercurial.sh
来代替~/.bashrc
中的/etc/bash_completion
:# 使用 bash-completion(如果可用)
如果 [ -f /etc/bash_completion.d/mercurial.sh ];然后
。 /etc/bash_completion.d/mercurial.sh
fi
不确定操作系统是否需要进行这种区分,但这对我在 Fedora 11 到 20 上有效。
更正: Fedora 11 和 Fedora 20。(未测试 12-19。)
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.)
在您的 Linux 中安装 bash-completion 软件包(取决于您使用的 Linux 发行版)。
然后转到
/etc/bash_completion.d/
并创建一个名为hg
的文件并将此脚本的内容(如下)放入创建的
hg
文件中。http://fts. ifac.cnr.it/cgi-bin/dwww/usr/share/doc/bash/completion-contrib/hg
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 calledhg
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