mirror of
https://github.com/dcarrillo/prezto.git
synced 2025-06-14 08:41:43 +00:00
Merge completions into functions
Completions are nothing more than auto-loadable functions prefixed with an underscore placed somewhere in $FPATH.
This commit is contained in:
44
modules/git/functions/_git-hub
Normal file
44
modules/git/functions/_git-hub
Normal file
@ -0,0 +1,44 @@
|
||||
#compdef git-hub
|
||||
#autoload
|
||||
|
||||
#
|
||||
# Completes git-hub.
|
||||
#
|
||||
# Authors:
|
||||
# Sorin Ionescu <sorin.ionescu@gmail.com>
|
||||
#
|
||||
|
||||
local state remotes remote branches files ret=1
|
||||
|
||||
_arguments -C -s -S \
|
||||
'1::args:->remote' \
|
||||
'2::args:->branch' \
|
||||
'3::args:->file' && ret=0
|
||||
|
||||
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=($(
|
||||
git branch -r \
|
||||
| grep "${remote}/" \
|
||||
| sed \
|
||||
-e "/${remote}\/HEAD -> ${remote}/d" \
|
||||
-e "s/^[[:space:]]*${remote}\///g"
|
||||
))
|
||||
_describe -t branch 'branches' branches && 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
|
||||
|
12
modules/git/functions/_git-hub-short-url
Normal file
12
modules/git/functions/_git-hub-short-url
Normal file
@ -0,0 +1,12 @@
|
||||
#compdef git-hub-short-url
|
||||
#autoload
|
||||
|
||||
#
|
||||
# Completes git-hub-short-url.
|
||||
#
|
||||
# Authors:
|
||||
# Sorin Ionescu <sorin.ionescu@gmail.com>
|
||||
#
|
||||
|
||||
_arguments '1:url:' && return 0
|
||||
|
15
modules/git/functions/_git-info
Normal file
15
modules/git/functions/_git-info
Normal file
@ -0,0 +1,15 @@
|
||||
#compdef git-info
|
||||
#autoload
|
||||
|
||||
#
|
||||
# Completes git-info.
|
||||
#
|
||||
# Authors:
|
||||
# Sorin Ionescu <sorin.ionescu@gmail.com>
|
||||
#
|
||||
|
||||
_arguments "1:toggle:((
|
||||
on\:'enable in-prompt information for the current repository'
|
||||
off\:'disable in-prompt information for the current repository'
|
||||
))" && return 0
|
||||
|
Reference in New Issue
Block a user