Created
June 4, 2015 15:31
-
-
Save greuze/9249c362d630ef465bb6 to your computer and use it in GitHub Desktop.
Autocomplete grunt task if Gruntfile.js is present
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Create function that will run when a certain phrase is typed in terminal | |
# and tab key is pressed twice | |
_grunt_complete() | |
{ | |
# fill local variable with a list of completions | |
local COMPLETES=`grep -s 'grunt\.registerTask' Gruntfile.js | sed "s/\s*grunt.registerTask('\([^']*\)',.*$/\1/g"` | |
# we put the completions into $COMPREPLY using compgen | |
COMPREPLY=( $(compgen -W "$COMPLETES" -- ${COMP_WORDS[COMP_CWORD]}) ) | |
return 0 | |
} | |
# get completions for command 'grunt' from function '_grunt_complete()' | |
complete -F _grunt_complete grunt |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment