1
0
Fork 0
mirror of https://github.com/ohmyzsh/ohmyzsh.git synced 2024-12-22 20:31:57 +00:00
ohmyzsh/plugins/grails/grails.plugin.zsh

61 lines
1.4 KiB
Bash
Raw Normal View History

2011-09-10 10:48:40 +00:00
_enumerateGrailsScripts() {
# Default directories
2011-09-10 10:48:40 +00:00
directories=($GRAILS_HOME/scripts ~/.grails/scripts ./scripts)
# Check all of the plugins directories, if they exist
if [ -d plugins ]
then
directories+=(plugins/*/scripts)
fi
2011-09-10 10:48:40 +00:00
# Enumerate all of the Groovy files
files=()
for dir in $directories;
do
if [ -d $dir ]
then
files+=($dir/[^_]*.groovy)
2011-09-10 10:48:40 +00:00
fi
done
2011-09-10 10:48:40 +00:00
# Don't try to basename ()
if [ ${#files} -eq 0 ];
then
return
fi
scripts=()
for file in $files
do
# - Strip the path
# - Remove all scripts with a leading '_'
# - PackagePlugin_.groovy -> PackagePlugin
# - PackagePlugin -> Package-Plugin
# - Package-Plugin -> package-plugin
command=$(basename $file \
| sed -E -e 's/^_?([^_]+)_?.groovy/\1/'\
-e 's/([a-z])([A-Z])/\1-\2/g' \
| tr "[:upper:]" "[:lower:]" \
| sort \
| uniq)
scripts+=($command)
done
echo $scripts
2011-09-10 10:48:40 +00:00
}
2011-09-10 10:48:40 +00:00
_grails() {
if (( CURRENT == 2 )); then
scripts=( $(_enumerateGrailsScripts) )
2011-09-10 10:48:40 +00:00
if [ ${#scripts} -ne 0 ];
then
_multi_parts / scripts
return
fi
fi
2011-09-10 10:48:40 +00:00
_files
}
2011-09-10 10:48:40 +00:00
compdef _grails grails