From 538c19b32f7b2c9bee22c23e3cb82a9ca90fb7b0 Mon Sep 17 00:00:00 2001 From: Gurkirat Singh Date: Sun, 10 Jan 2021 19:24:47 +0530 Subject: [PATCH] formatted gulp completion and used helper function --- completion/available/gulp.completion.bash | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/completion/available/gulp.completion.bash b/completion/available/gulp.completion.bash index 91e28764..d564931a 100644 --- a/completion/available/gulp.completion.bash +++ b/completion/available/gulp.completion.bash @@ -39,12 +39,16 @@ # # eval "$(gulp --completion=bash)" # Enable bash autocompletion. -function _gulp_completions() { -# The currently-being-completed word. -local cur="${COMP_WORDS[COMP_CWORD]}" -#Grab tasks -local compls=$(gulp --tasks-simple) -# Tell complete what stuff to show. -COMPREPLY=($(compgen -W "$compls" -- "$cur")) -} -complete -o default -F _gulp_completions gulp + +if _command_exists gulp +then + function _gulp_completions() { + # The currently-being-completed word. + local cur="${COMP_WORDS[COMP_CWORD]}" + #Grab tasks + local compls=$(gulp --tasks-simple) + # Tell complete what stuff to show. + COMPREPLY=($(compgen -W "$compls" -- "$cur")) + } + complete -o default -F _gulp_completions gulp +fi