如何为 Git 命令设置自动完成功能? [英] How can I set up autocompletion for Git commands?
问题描述
我有 Git(版本 1.7.2.5)bash 完成在我的 Debian 挤压(6.0)上工作.Git 是用 aptitude 安装的,我使用的是标准 debian 的 bash
,它支持命令行自动完成.
I have Git (version 1.7.2.5) bash compeletion working on my Debian squeeze (6.0). Git was installed with aptitude and I am using standard debian's bash
, which supports command line autocompletion.
现在,我刚刚在另一台机器(Lenny/Debian 5.0)上安装了 Git(1.5.6.5)并且没有自动完成功能.
Now, I just installed Git (1.5.6.5) on an other machine (Lenny/Debian 5.0) and the there is no autocompletion.
为什么 Git 自动完成功能在第二台机器上不起作用?我该如何诊断?
Why is Git autocomplete not working on the second machine? How do I diagnose this?
是什么使我的机器上的完成工作?我已经寻找文件 git-completion.bash
但它似乎不在我的机器上.Git 是如何完成的?
What is making completion work on my machine? I have looked for the file git-completion.bash
but it doesn't seem to be on my machine. How does Git complete ever work?
如何将 git complete 带到另一台机器上?
How can I bring git complete to the other machine?
推荐答案
你需要source/etc/bash_completion.d/git
来开启git自动补全.
You need to source /etc/bash_completion.d/git
to enable git auto-completion.
在我的 .bashrc
中完成了:
for file in /etc/bash_completion.d/* ; do
source "$file"
done
这篇关于如何为 Git 命令设置自动完成功能?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!