mirror of
https://github.com/dcarrillo/prezto.git
synced 2025-06-14 10:51:41 +00:00
Rename git-hub to git-hub-browse
This commit is contained in:
46
modules/git/functions/_git-hub-browse
Normal file
46
modules/git/functions/_git-hub-browse
Normal file
@ -0,0 +1,46 @@
|
||||
#compdef git-hub
|
||||
#autoload
|
||||
|
||||
#
|
||||
# Completes git-hub-browse
|
||||
#
|
||||
# Authors:
|
||||
# Sorin Ionescu <sorin.ionescu@gmail.com>
|
||||
#
|
||||
|
||||
local state remotes remote branches_or_tags branches tags files ret=1
|
||||
|
||||
_arguments -C -s -S \
|
||||
'1::args:->remote' \
|
||||
'2::args:->branch-or-tag' \
|
||||
'3::args:->file' && ret=0
|
||||
|
||||
case "$state" in
|
||||
(remote)
|
||||
remotes=($(
|
||||
git config --local --get-regexp 'remote.*.url' \
|
||||
| awk 'BEGIN {FS="."} ; {print $2}'
|
||||
))
|
||||
_describe -t branch 'remotes' remotes && ret=0
|
||||
;;
|
||||
(branch-or-tag)
|
||||
remote="$words[(($CURRENT - 1))]"
|
||||
|
||||
branches_or_tags=($(
|
||||
git ls-remote --heads --tags "$remote" | awk '{print $2}'
|
||||
))
|
||||
|
||||
branches=(HEAD ${${(M)branches_or_tags[@]##refs/heads/?##}##refs/heads/})
|
||||
tags=(${${(M)branches_or_tags[@]##refs/tags/?##}##refs/tags/})
|
||||
|
||||
_describe -t branch 'branches' branches && ret=0
|
||||
_describe -t tag 'tags' tags && ret=0
|
||||
;;
|
||||
(file)
|
||||
files=(${(0)"$(_call_program files git ls-files -z --exclude-standard 2>/dev/null)"})
|
||||
_wanted file expl 'file' _multi_parts - / files && ret=0
|
||||
;;
|
||||
esac
|
||||
|
||||
return $ret
|
||||
|
Reference in New Issue
Block a user