mirror of
https://github.com/ohmyzsh/ohmyzsh.git
synced 2024-11-26 21:51:05 +01:00
[plugins/grails] Added grails plugin
This commit is contained in:
parent
762b55bb2b
commit
c6e8c856cb
1 changed files with 62 additions and 0 deletions
62
plugins/grails/grails.plugin.zsh
Executable file
62
plugins/grails/grails.plugin.zsh
Executable file
|
@ -0,0 +1,62 @@
|
||||||
|
|
||||||
|
if [[ ! -d $GRAILS_HOME/scripts ]];
|
||||||
|
then
|
||||||
|
echo "$0:"
|
||||||
|
echo "Please set \$GRAILS_HOME to use the 'grails' plugin, and ensure that \$GRAILS_HOME/scripts exists"
|
||||||
|
fi
|
||||||
|
|
||||||
|
_enumerateGrailsScripts() {
|
||||||
|
# Default directoryies
|
||||||
|
directories=($GRAILS_HOME/scripts ~/.grails/scripts ./scripts)
|
||||||
|
|
||||||
|
# Check all of the plugins directories, if they exist
|
||||||
|
if [ -d plugins ]
|
||||||
|
then
|
||||||
|
directories+=(plugins/*/scripts)
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Enumerate all of the Groovy files
|
||||||
|
files=()
|
||||||
|
for dir in $directories;
|
||||||
|
do
|
||||||
|
if [ -d $dir ]
|
||||||
|
then
|
||||||
|
files+=($dir/*.groovy)
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
# Don't try to basename ()
|
||||||
|
if [ ${#files} -eq 0 ];
|
||||||
|
then
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
|
||||||
|
# - Strip the path
|
||||||
|
# - Remove all scripts with a leading '_'
|
||||||
|
# - PackagePlugin_.groovy -> PackagePlugin
|
||||||
|
# - PackagePlugin -> Package-Plugin
|
||||||
|
# - Package-Plugin -> package-plugin
|
||||||
|
basename $files \
|
||||||
|
| grep -vE -e '^_' \
|
||||||
|
| sed -E -e 's/^_?([^_]+)_?.groovy/\1/'\
|
||||||
|
-e 's/([a-z])([A-Z])/\1-\2/g' \
|
||||||
|
| tr "[:upper:]" "[:lower:]" \
|
||||||
|
| sort \
|
||||||
|
| uniq
|
||||||
|
}
|
||||||
|
|
||||||
|
_grails() {
|
||||||
|
if (( CURRENT == 2 )); then
|
||||||
|
scripts=( $(_enumerateGrailsScripts) )
|
||||||
|
|
||||||
|
if [ ${#scripts} -ne 0 ];
|
||||||
|
then
|
||||||
|
_multi_parts / scripts
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
_files
|
||||||
|
}
|
||||||
|
|
||||||
|
compdef _grails grails
|
Loading…
Reference in a new issue