my xfce4 dotfiles
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

60 lines
1.4 KiB

3 years ago
  1. _enumerateGrailsScripts() {
  2. # Default directories
  3. directories=($GRAILS_HOME/scripts ~/.grails/scripts ./scripts)
  4. # Check all of the plugins directories, if they exist
  5. if [ -d plugins ]
  6. then
  7. directories+=(plugins/*/scripts)
  8. fi
  9. # Enumerate all of the Groovy files
  10. files=()
  11. for dir in $directories;
  12. do
  13. if [ -d $dir ]
  14. then
  15. files+=($dir/[^_]*.groovy)
  16. fi
  17. done
  18. # Don't try to basename ()
  19. if [ ${#files} -eq 0 ];
  20. then
  21. return
  22. fi
  23. scripts=()
  24. for file in $files
  25. do
  26. # - Strip the path
  27. # - Remove all scripts with a leading '_'
  28. # - PackagePlugin_.groovy -> PackagePlugin
  29. # - PackagePlugin -> Package-Plugin
  30. # - Package-Plugin -> package-plugin
  31. command=$(basename $file \
  32. | sed -E -e 's/^_?([^_]+)_?.groovy/\1/'\
  33. -e 's/([a-z])([A-Z])/\1-\2/g' \
  34. | tr "[:upper:]" "[:lower:]" \
  35. | sort \
  36. | uniq)
  37. scripts+=($command)
  38. done
  39. echo $scripts
  40. }
  41. _grails() {
  42. if (( CURRENT == 2 )); then
  43. scripts=( $(_enumerateGrailsScripts) )
  44. if [ ${#scripts} -ne 0 ];
  45. then
  46. _multi_parts / scripts
  47. return
  48. fi
  49. fi
  50. _files
  51. }
  52. compdef _grails grails