1
0
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:
Sorin Ionescu
2012-04-02 20:18:03 -04:00
parent aa0c1faa19
commit 9d8187ba6b
12 changed files with 6 additions and 6 deletions

View 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

View 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

View 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