Bash 中 Mercurial 的 Tab 完成?

Jon*_*nik 7 bash autocomplete mercurial

在命令行上使用 Subversion,它可以智能地完成可用的子命令等:

$ svn c<tab>
cat         checkout    cl          co          copy        
changelist  ci          cleanup     commit      cp  
Run Code Online (Sandbox Code Playgroud)

另一方面,Mercurial 似乎没有制表符完成功能,至少开箱即用:

$ hg c<tab> 
[nothing happens]
Run Code Online (Sandbox Code Playgroud)

Mercurial 的 Bash 补全是否可用?让它工作的最简单方法是什么?我在 Ubuntu 11.04 上。

Pet*_*zel 7

Mercurial 发布了它自己的 bash 完成 - 请参阅 tarball 中的 contrib/bash_completion。至少在 openSUSE 上,这个文件被安装到 /etc/bash_completion.d/,以便 mercurial 的 bash 完成自动工作。如果安装了完成脚本,您可能需要检查 Ubuntu 的 mercurial 包。


Pao*_*olo 6

我从源代码版本构建了 mercurial,并且必须自己安装完成脚本。这是如何做到这一点:

$ cd
$ wget http://selenic.com/hg/raw-file/25e4d2f35965/contrib/bash_completion -P opt/packages/mercurial
$ echo ". opt/packages/mercurial/bash_completion" >> .bashrc
$ . opt/packages/mercurial/bash_completion
Run Code Online (Sandbox Code Playgroud)

完成已开启。


max*_*zig 4

在 Ubuntu 10.04 中,它对我来说是开箱即用的。在bash中:

$ hg c
cat       checkout  clone     commit    copy
Run Code Online (Sandbox Code Playgroud)

或者在 zsh 中:

$ hg c
cat       checkout  ci        clone     co        commit    copy      cp
Run Code Online (Sandbox Code Playgroud)

也许您缺少一个包(或者您遇到了错误)。

在我的系统上,完成文件由 Mercurial 包提供:

$ dpkg -S /etc/bash_completion.d/mercurial 
mercurial: /etc/bash_completion.d/mercurial
Run Code Online (Sandbox Code Playgroud)