Skip to content

Commit

Permalink
[v2] Update zsh tab completion script
Browse files Browse the repository at this point in the history
Closes #28
  • Loading branch information
simonwhitaker committed Jun 12, 2018
1 parent 3a5ab93 commit 2530990
Showing 1 changed file with 41 additions and 7 deletions.
48 changes: 41 additions & 7 deletions shell-completions/gibo-completion.zsh
Original file line number Diff line number Diff line change
Expand Up @@ -17,22 +17,56 @@
#
# fpath=(~/.zsh $fpath)
#
#
# CONTRIBUTING
#
# See https://github.com/zsh-users/zsh-completions/blob/master/zsh-completions-howto.org
# for tips on writing and testing zsh completion functions.
#
# CREDITS
#
# Written by Simon Whitaker <sw@netcetera.org>

_gibo()
_gibo_commands()
{
_gibo_commands=(
'dump:Dump one or more boilerplates' \
'list:List available boilerplates' \
'update:Update list of available boilerplates' \
'help:Display this help text' \
'version:Display current script version'
)
_describe 'command' _gibo_commands
}

_gibo_dump_commands()
{
local local_repo=${GIBO_BOILERPLATES:-"$HOME/.gitignore-boilerplates"}
local -a boilerplates
if [ -e "$local_repo" ]; then
boilerplates=($local_repo/**/*.gitignore(:r:t))
fi

_arguments \
{-l,--list}'[List available boilerplates]' \
{-u,--upgrade}'[Upgrade list of available boilerplates]' \
{-h,--help}'[Display this help text]' \
{-v,--version}'[Display current script version]' \
"*:boilerplate:($boilerplates)"
_arguments "*:boilerplate:($boilerplates)"
}

_gibo()
{
local ret=1

_arguments -C \
'1: :_gibo_commands' \
'*::arg:->args' \
&& ret=0

case $state in
args )
case $line[1] in
dump )
_arguments \
'*: :_gibo_dump_commands' \
&& ret=0
;;
esac
esac
}

0 comments on commit 2530990

Please sign in to comment.