2012-01-19 23:32:27 +01:00
|
|
|
#compdef git-hub
|
|
|
|
#autoload
|
|
|
|
|
2012-02-01 05:37:51 +01:00
|
|
|
#
|
|
|
|
# Completes git-hub.
|
|
|
|
#
|
|
|
|
# Authors:
|
|
|
|
# Sorin Ionescu <sorin.ionescu@gmail.com>
|
|
|
|
#
|
|
|
|
|
2012-02-03 00:25:21 +01:00
|
|
|
local state remotes remote branches files ret=1
|
2012-01-19 23:32:27 +01:00
|
|
|
|
|
|
|
_arguments -C -s -S \
|
|
|
|
'1::args:->remote' \
|
2012-02-03 00:25:21 +01:00
|
|
|
'2::args:->branch' \
|
|
|
|
'3::args:->file' && ret=0
|
2012-01-19 23:32:27 +01:00
|
|
|
|
|
|
|
case "$state" in
|
|
|
|
(remote)
|
|
|
|
remotes=($(
|
|
|
|
git config -l \
|
|
|
|
| grep 'remote\.[^.]*\.url' \
|
|
|
|
| cut -d'.' -f2))
|
|
|
|
_describe -t branch 'remotes' remotes && ret=0
|
|
|
|
;;
|
|
|
|
(branch)
|
|
|
|
remote="$words[(($CURRENT - 1))]"
|
|
|
|
branches=($(
|
2012-01-24 06:50:51 +01:00
|
|
|
git branch -r \
|
2012-02-02 22:50:47 +01:00
|
|
|
| grep "${remote}/" \
|
2012-01-24 06:50:51 +01:00
|
|
|
| sed \
|
|
|
|
-e "/${remote}\/HEAD -> ${remote}/d" \
|
|
|
|
-e "s/^[[:space:]]*${remote}\///g"
|
2012-01-19 23:32:27 +01:00
|
|
|
))
|
|
|
|
_describe -t branch 'branches' branches && ret=0
|
|
|
|
;;
|
2012-02-03 00:25:21 +01:00
|
|
|
(file)
|
|
|
|
files=(${(0)"$(_call_program files git ls-files -z --exclude-standard 2>/dev/null)"})
|
|
|
|
_wanted file expl 'file' _multi_parts - / files && ret=0
|
|
|
|
;;
|
2012-01-19 23:32:27 +01:00
|
|
|
esac
|
|
|
|
|
|
|
|
return $ret
|
2012-01-21 01:48:24 +01:00
|
|
|
|