Added git completion to zsh

This commit is contained in:
Michael Mandl 2020-05-24 12:55:20 +02:00
parent db2c1a6ee2
commit 70d93acb15
2 changed files with 18 additions and 0 deletions

16
fzf/git-completion.zsh Normal file
View file

@ -0,0 +1,16 @@
_fzf_complete_git() {
ARGS="$@"
local branches
branches=$(git branch --all --sort=-committerdate --format="%(refname:short)")
if [[ $ARGS == 'git co'* || $ARGS == 'git checkout'* || $ARGS == 'git merge'* ]]; then
_fzf_complete -- "$@" < <(
echo $branches
)
else
eval "zle ${fzf_default_compeltion:-expand-or-complete}"
fi
}
_fzf_complete_git_post() {
sed "s/^origin\///"
}

View file

@ -112,3 +112,5 @@ export EDITOR='nvim'
# alias ohmyzsh="mate ~/.oh-my-zsh"
[ -f ~/.fzf.zsh ] && source ~/.fzf.zsh
[ -f ~/.dotfiles/fzf/git-completion.zsh ] && source ~/.dotfiles/fzf/git-completion.zsh