为 Mercurial (hg) 启用 bash Tab 补全

发布于 2024-12-11 19:39:38 字数 83 浏览 0 评论 0原文

我已经在 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(6

奶茶白久 2024-12-18 19:39:38

您需要

  • 安装最新的 Mercurial 软件包,请参阅 Mercurial PPA。这将为您提供一个 /etc/bash_completion.d/mercurial 文件,其中包含 Mercurial 的完成代码。您可以直接获取此文件以启用 Mercurial 的完成支持。

您还可以为所有程序启用完成支持:

  • 安装bash-completion软件包:aptitude install bash-completion

  • ~/.bashrc 文件中源 /etc/bash_completion

    # 使用 bash-completion(如果可用)
    如果 [ -f /etc/bash_completion ];然后
      。 /etc/bash_completion
    菲
    

    这将为所有命令启用补全,包括 Mercurial。

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.

怪我闹别瞎闹 2024-12-18 19:39:38
curl https://www.mercurial-scm.org/repo/hg/raw-file/tip/contrib/bash_completion -o ~/.hg-completion.bash && source ~/.hg-completion.bash

Mercurial 自动完成脚本似乎保留在此处:

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

source 此脚本位于您的 .bashrc或同等水平

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

飘落散花 2024-12-18 19:39:38

系统范围内的

所有用户。

$ 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

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
魔法少女 2024-12-18 19:39:38

bash_completion 脚本位置已更改,因此您需要执行

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

以下操作

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

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
南汐寒笙箫 2024-12-18 19:39:38

由于它既没有标记也没有标题“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.shinstead 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.)

满天都是小星星 2024-12-18 19:39:38

在您的 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 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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文