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.
47 lines
1.1 KiB
47 lines
1.1 KiB
13 years ago
|
#compdef git-hub
|
||
|
#autoload
|
||
|
|
||
13 years ago
|
#
|
||
12 years ago
|
# Completes git-hub-browse
|
||
13 years ago
|
#
|
||
|
# Authors:
|
||
|
# Sorin Ionescu <sorin.ionescu@gmail.com>
|
||
|
#
|
||
|
|
||
12 years ago
|
local state remotes remote branches_or_tags branches tags files ret=1
|
||
13 years ago
|
|
||
|
_arguments -C -s -S \
|
||
|
'1::args:->remote' \
|
||
12 years ago
|
'2::args:->branch-or-tag' \
|
||
13 years ago
|
'3::args:->file' && ret=0
|
||
13 years ago
|
|
||
|
case "$state" in
|
||
|
(remote)
|
||
|
remotes=($(
|
||
12 years ago
|
git config --local --get-regexp 'remote.*.url' \
|
||
|
| awk 'BEGIN {FS="."} ; {print $2}'
|
||
|
))
|
||
13 years ago
|
_describe -t branch 'remotes' remotes && ret=0
|
||
|
;;
|
||
12 years ago
|
(branch-or-tag)
|
||
13 years ago
|
remote="$words[(($CURRENT - 1))]"
|
||
12 years ago
|
|
||
|
branches_or_tags=($(
|
||
|
git ls-remote --heads --tags "$remote" | awk '{print $2}'
|
||
13 years ago
|
))
|
||
12 years ago
|
|
||
|
branches=(HEAD ${${(M)branches_or_tags[@]##refs/heads/?##}##refs/heads/})
|
||
|
tags=(${${(M)branches_or_tags[@]##refs/tags/?##}##refs/tags/})
|
||
|
|
||
13 years ago
|
_describe -t branch 'branches' branches && ret=0
|
||
12 years ago
|
_describe -t tag 'tags' tags && ret=0
|
||
13 years ago
|
;;
|
||
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
|
|