formatted grunt completion and used helper function
parent
f790ba2659
commit
475393c6b7
|
|
@ -41,10 +41,13 @@
|
|||
# eval "$(grunt --completion=bash)"
|
||||
|
||||
# Search the current directory and all parent directories for a gruntfile.
|
||||
function _grunt_gruntfile() {
|
||||
|
||||
if _command_exists grunt
|
||||
then
|
||||
function _grunt_gruntfile() {
|
||||
local curpath="$PWD"
|
||||
while [[ "$curpath" ]]; do
|
||||
for gruntfile in "$curpath/"{G,g}runtfile.{js,coffee}; do
|
||||
for gruntfile in "$curpath/"{G,g}runtfile{.js,.coffee,}; do
|
||||
if [[ -e "$gruntfile" ]]; then
|
||||
echo "$gruntfile"
|
||||
return
|
||||
|
|
@ -53,10 +56,10 @@ function _grunt_gruntfile() {
|
|||
curpath="${curpath%/*}"
|
||||
done
|
||||
return 1
|
||||
}
|
||||
}
|
||||
|
||||
# Enable bash autocompletion.
|
||||
function _grunt_completions() {
|
||||
# Enable bash autocompletion.
|
||||
function _grunt_completions() {
|
||||
# The currently-being-completed word.
|
||||
local cur="${COMP_WORDS[COMP_CWORD]}"
|
||||
# The current gruntfile, if it exists.
|
||||
|
|
@ -70,6 +73,7 @@ function _grunt_completions() {
|
|||
[[ "$cur" == -* ]] && compls="$compls $opts"
|
||||
# Tell complete what stuff to show.
|
||||
COMPREPLY=($(compgen -W "$compls" -- "$cur"))
|
||||
}
|
||||
}
|
||||
|
||||
complete -o default -F _grunt_completions grunt
|
||||
complete -o default -F _grunt_completions grunt
|
||||
fi
|
||||
|
|
|
|||
Loading…
Reference in New Issue