例如,在一台新的ubuntu机器上,我刚刚运行了sudo apt-get git,在输入例如git check[tab]时没有完成。
我在http://git-scm.com/docs上没有找到任何东西,但IIRC完成是包含在这些天的git包中,我只需要在我的bashrc中正确的条目。
例如,在一台新的ubuntu机器上,我刚刚运行了sudo apt-get git,在输入例如git check[tab]时没有完成。
我在http://git-scm.com/docs上没有找到任何东西,但IIRC完成是包含在这些天的git包中,我只需要在我的bashrc中正确的条目。
当前回答
我也有同样的问题,遵循以下步骤:
curl https://raw.githubusercontent.com/git/git/master/contrib/completion/git-completion.bash -o ~/.git-completion.bash
然后将以下行添加到.bash_profile(通常在您的主文件夹下)
if [ -f ~/.git-completion.bash ]; then
. ~/.git-completion.bash
fi
来源:http://code-worrier.com/blog/autocomplete-git/
其他回答
只需在.bashrc中输入下面的内容,然后重新启动终端。导航到Git repo以查看提示符中的路径。
PS1='\[\033[0;32m\]\[\033[0m\033[0;32m\]\u\[\033[0;36m\] @ \[\033[0;36m\]\h \w\[\033[0;32m\]$(__git_ps1)\n\[\033[0;32m\]└─\[\033[0m\033[0;32m\] \$\[\033[0m\033[0;32m\] ▶\[\033[0m\] '
我也有同样的问题,遵循以下步骤:
curl https://raw.githubusercontent.com/git/git/master/contrib/completion/git-completion.bash -o ~/.git-completion.bash
然后将以下行添加到.bash_profile(通常在您的主文件夹下)
if [ -f ~/.git-completion.bash ]; then
. ~/.git-completion.bash
fi
来源:http://code-worrier.com/blog/autocomplete-git/
参见https://github.com/git/git/blob/master/contrib/completion/git-completion.bash
您只需要获取完成脚本的源代码
Ubuntu 14.10
安装git-core和bash-completion
sudo apt-get install -y git-core bash-completion
对于当前会话使用情况 源/usr/share/bash-completion /完成/ git 在所有会议上都开着 Echo "source /usr/share/bash-completion/completion /git" >> ~/.bashrc
只需在~/.bashrc中这样做:
source /usr/share/bash-completion/completions/git
其他答案告诉你安装bash-completion,你不需要这样做,但如果你这样做,那么就不需要直接源完成。你只能做其中一个,不能两个都做。
一个更通用的解决方案是查询bash-completion项目推荐的系统位置:
source "$(pkg-config --variable=completionsdir bash-completion)"/git