Updated Grails Autocomplete Script for Zsh

| Comments

A couple of years ago, I created a grails auto-completion script for bash and zsh.

Since then, I’ve completely abandoned bash, in favor of zsh (which I consider to be the superior shell) and I’d been getting annoyed at a few issues in the last grails autocomplete script.

I finally got motivated to make some enhancements to it. Including support for grails 1.2 plugin scripts (1.2 moved the plugins into the ~/.grails directory), and support for test class name autocompletion (very useful for grails test-app).

To get it working (assuming you’re using zsh), you can either add the contents of my zshrc_grails_compinstall to your .zshrc file, or you can switch over to using my full zshrc setup, which has a number of nice features that I’ve collected over the years. I’ll also continue to update this as I think of new tricks.

After getting it installed, just type “grails” followed by a space and then hit tab. It will show you a list of all of the potential grails scripts for the application that you’re in. It’s aware of the version of the current app, as well as it’s application name based on the contents of application.properties, and also will include any scripts for the plugins you have installed in that app in ~/.grails/GRAILS_VERSION/projects/APP_NAME/plugins (in addition to the scripts in ./scripts, $GRAILS_HOME/scripts and ~/.grails/scripts).

After you choose your script (such as grails test-app hit space again and it will show you all of the test classes, with the full package for the class, under your test directory.