例如,在一台新的ubuntu机器上,我刚刚运行了sudo apt-get git
,但在输入git check[tab]
时没有补全。
我在http://git-scm.com/docs上没有找到任何东西,但是现在git包中已经包含了IIRC补全,我只需要在我的bashrc中输入正确的条目。
发布于 2013-09-19 23:16:52
在Linux上
在大多数发行版中,当您安装git时,git完成脚本会安装到/etc/bash_completion.d/
(或/usr/share/bash-completion/completions/git
)中,不需要转到github。您只需要使用它-将这一行添加到您的.bashrc
source /etc/bash_completion.d/git
# or
source /usr/share/bash-completion/completions/git
在某些版本的Ubuntu中,默认情况下git autocomplete可能会被破坏,通过运行以下命令重新安装应该可以修复它:
sudo apt-get install git-core bash-completion
在Mac上
您可以使用Homebrew或MacPorts安装git completion。
自制软件
如果$BASH_VERSION
> 4:brew install bash-completion@2
(更新版),请特别注意3.2.57(1)-release附带的MacOS默认版本。
添加到.bash_profile
[[ -r "/usr/local/etc/profile.d/bash_completion.sh" ]] && . "/usr/local/etc/profile.d/bash_completion.sh"
对于旧版本的bash:brew install bash-completion
添加到.bash_profile
[ -f /usr/local/etc/bash_completion ] && . /usr/local/etc/bash_completion
MacPorts
sudo port install git +bash_completion
然后将其添加到您的.bash_profile
中
if [ -f /usr/share/bash-completion/bash_completion ]; then
. /usr/share/bash-completion/bash_completion
fi
有关更多信息,请访问本指南:Install Bash git completion
请注意,在所有情况下,您都需要创建一个新的shell (打开一个新的终端选项卡/窗口)才能使更改生效。
发布于 2013-11-09 21:13:43
我也遇到了同样的问题,请执行以下步骤:
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
发布于 2012-09-13 11:30:02
https://stackoverflow.com/questions/12399002
复制相似问题