Jesse over at Refactr posted a nice tip about using tab completion for the ssh command. It grabs host names and IPs out of the ssh known_hosts file.
That got me to thinking that it would be pretty useful to have tab completion of Grails commands available. At my company, we’ve written about 20 custom Gant scripts and it can sometimes be a problem to remember their names. Running “grails help” often takes too long, so I probably ls scripts once a day or so to remind myself if it’s clean-db or clear-db.
I did a quick google search and found that Scott Davis posted some instructions about a year ago (originally by Doyle@DoyleCentral).
It was a good start, but there were two issues I had with the solution. The first is that it only worked in bash (I prefer zsh) and the second is that it used a static list of script names stored in the GRAILS_HOME directory. Any new scripts, or app specific scripts would need to be manually added to the static list.
Grails Gant scripts can exist in 4 possible locations:
- $GRAILS_HOME/scripts
- $USER_HOME/.grails/scripts
- $PROJECT_HOME/scripts
- $PROJECT_HOME/plugins/*/scripts
After some playing around, I was able to come up with a bash script that allows for real-time completion of all four potential script repositories. $PROJECT_HOME is considered to be the current directory, so if you’re not in a grails app, you’ll only see completion scripts for the first two.
Continue Reading »
Posted by tednaleid / command line and grails and osx