diff options
author | Stephen Zhuang <stephen.zhuang@gmail.com> | 2013-01-06 14:10:42 +0800 |
---|---|---|
committer | Stephen Zhuang <stephen.zhuang@gmail.com> | 2013-01-06 14:10:42 +0800 |
commit | 914c47b3473b000288c693523f83fde998282a81 (patch) | |
tree | a29cf3d796544a3b2807e26812011cda51f644a9 /plugins/gitfast/_git | |
parent | 692dca07158413ae27b2064c303240f5b9621cff (diff) | |
parent | 80a603259657acab97badbae20003b5a34c901f9 (diff) | |
download | zsh-914c47b3473b000288c693523f83fde998282a81.tar.gz zsh-914c47b3473b000288c693523f83fde998282a81.tar.bz2 zsh-914c47b3473b000288c693523f83fde998282a81.zip |
Merge remote-tracking branch 'upstream/master'
Diffstat (limited to 'plugins/gitfast/_git')
-rw-r--r-- | plugins/gitfast/_git | 78 |
1 files changed, 78 insertions, 0 deletions
diff --git a/plugins/gitfast/_git b/plugins/gitfast/_git new file mode 100644 index 000000000..45775021f --- /dev/null +++ b/plugins/gitfast/_git @@ -0,0 +1,78 @@ +#compdef git gitk + +# zsh completion wrapper for git +# +# You need git's bash completion script installed somewhere, by default on the +# same directory as this script. +# +# If your script is on ~/.git-completion.sh instead, you can configure it on +# your ~/.zshrc: +# +# zstyle ':completion:*:*:git:*' script ~/.git-completion.sh +# +# The recommended way to install this script is to copy to +# '~/.zsh/completion/_git', and then add the following to your ~/.zshrc file: +# +# fpath=(~/.zsh/completion $fpath) + +complete () +{ + # do nothing + return 0 +} + +zstyle -s ":completion:*:*:git:*" script script +test -z "$script" && script="$(dirname ${funcsourcetrace[1]%:*})"/git-completion.bash +ZSH_VERSION='' . "$script" + +__gitcomp () +{ + emulate -L zsh + + local cur_="${3-$cur}" + + case "$cur_" in + --*=) + ;; + *) + local c IFS=$' \t\n' + local -a array + for c in ${=1}; do + c="$c${4-}" + case $c in + --*=*|*.) ;; + *) c="$c " ;; + esac + array+=("$c") + done + compset -P '*[=:]' + compadd -Q -S '' -p "${2-}" -a -- array && _ret=0 + ;; + esac +} + +__gitcomp_nl () +{ + emulate -L zsh + + local IFS=$'\n' + compset -P '*[=:]' + compadd -Q -S "${4- }" -p "${2-}" -- ${=1} && _ret=0 +} + +_git () +{ + local _ret=1 + () { + emulate -L ksh + local cur cword prev + cur=${words[CURRENT-1]} + prev=${words[CURRENT-2]} + let cword=CURRENT-1 + __${service}_main + } + let _ret && _default -S '' && _ret=0 + return _ret +} + +_git |