Git 自动完成在 bash 中不起作用
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/36795816/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Git Auto-complete not working in bash
提问by MysticCode
I recently installed git. I am using Ubuntu 14.04. However the autocomplete feature is not working.
我最近安装了 git。我正在使用 Ubuntu 14.04。但是,自动完成功能不起作用。
Whenever I type git i
then TABit should be git init
but it doesn't happen so. I have tried everything mentioned in this page, still no success.
每当我键入git i
那么TAB它应该是git init
,但它并没有这样发生。我已经尝试了本页中提到的所有内容,但仍然没有成功。
Whenever I do git in
then TABit seems like git is pinging unknown host. Below is the screenshot:
每当我做git in
那么TAB它似乎像Git是执行ping主机不明。下面是截图:
How do I resolve this?
我该如何解决?
回答by CodeWizard
Use this script for Ubuntu:
将此脚本用于 Ubuntu:
https://github.com/git/git/blob/master/contrib/completion/git-completion.bash
https://github.com/git/git/blob/master/contrib/completion/git-completion.bash
Read the documentation on how to set it up:
阅读有关如何设置的文档:
To use these routines:
1) Copy this file to somewhere (e.g. ~/.git-completion.bash).
2) Add the following line to your .bashrc/.zshrc:
source ~/.git-completion.bash
3) Consider changing your PS1 to also show the current branch,
see git-prompt.sh for details.
A shorter solution:
更短的解决方案:
# install the bash-completion vai apg-get
sudo apt-get install git bash-completion