Yes, save it in $HOME/.grails/scripts
. This way it will be available to all Grails installs.
Note that the naming convention is important; if the script starts with an underscore, it cannot be called directly as a script, only included in others (e.g. to store common code and methods). If it ends in an underscore, it can be called outside of a project (e.g. the create-app
script is named CreateApp_.groovy
). If there's no leading or trailing underscore then it can be called from within a project.