You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
45 lines
920 B
45 lines
920 B
13 years ago
|
#compdef git-hub
|
||
|
#autoload
|
||
|
|
||
13 years ago
|
#
|
||
|
# Completes git-hub.
|
||
|
#
|
||
|
# Authors:
|
||
|
# Sorin Ionescu <sorin.ionescu@gmail.com>
|
||
|
#
|
||
|
|
||
13 years ago
|
local state remotes remote branches files ret=1
|
||
13 years ago
|
|
||
|
_arguments -C -s -S \
|
||
|
'1::args:->remote' \
|
||
13 years ago
|
'2::args:->branch' \
|
||
|
'3::args:->file' && ret=0
|
||
13 years ago
|
|
||
|
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=($(
|
||
13 years ago
|
git branch -r \
|
||
13 years ago
|
| grep "${remote}/" \
|
||
13 years ago
|
| sed \
|
||
|
-e "/${remote}\/HEAD -> ${remote}/d" \
|
||
|
-e "s/^[[:space:]]*${remote}\///g"
|
||
13 years ago
|
))
|
||
|
_describe -t branch 'branches' branches && ret=0
|
||
|
;;
|
||
13 years ago
|
(file)
|
||
|
files=(${(0)"$(_call_program files git ls-files -z --exclude-standard 2>/dev/null)"})
|
||
|
_wanted file expl 'file' _multi_parts - / files && ret=0
|
||
|
;;
|
||
13 years ago
|
esac
|
||
|
|
||
|
return $ret
|
||
13 years ago
|
|