如果你用的是zsh
curl https://raw.githubusercontent.com/git/git/master/contrib/completion/git-completion.zsh -o ~/.git-completion.zsh
curl https://raw.githubusercontent.com/git/git/master/contrib/completion/git-completion.bash -o ~/.git-completion.bash
mkdir -p ~/.zsh/functions && cp ~/.git-completion.zsh ~/.zsh/functions/_git
在~/.zshrc
中添加:
zstyle ':completion:*:*:git:*' script ~/.git-completion.bash
# `compinit` scans $fpath, so do this before calling it.
fpath=(~/.zsh/functions $fpath)
autoload -Uz compinit && compinit
参考:
https://stackoverflow.com/questions/28028740/git-tab-completion-in-zsh-throwing-errors
如果你用的是bash:
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
source ~/.bash_profile
网友评论