Zsh completion for your tests and specs

Got zsh? Loving your TATFT but tired of typing out all those spec commands?

spec -cfs spec/controllers/application_controller_spec.rb

or test commands?

ruby -Itest test/functionals/admin/users_controller_test.rb

Well, put away that keyboard oil, because you’ll be saving keystrokes left and right!

[~/dev/railsapp] $ spc a<Tab>
admin/base_controller    application_controller  arrr_pirates_controller

[~/dev/railsapp] $ spc app<Tab>
admin/base_controller    application_controller  arrr_pirates_controller

[~/dev/railsapp] $ spc application_controller<Enter>
admin/base_controller    application_controller  arrr_pirates_controller

spec -cfs spec/controllers/application_controller_spec.rb # ta-da!

You can also complete multiple tests or specs in one line. Download the scripts and find out more in the zsh-rails-test-spec-shortcuts repository.

“I’m so tired of typing ruby -Itest test/… I’m so glad I installed the zsh completion scripts. I’ll spend all my saved energy on eating campsites and writing solid code!”

Bonus links

As a bonus, here’s a reminder of an oldie but a goodie, rake task completion for zsh: http://weblog.rubyonrails.org/2006/3/9/fast-rake-task-completion-for-zsh

And a recent one from the rubygems-developers list, for gem command completion for zsh: http://rubyforge.org/pipermail/rubygems-developers/2009-August/004860.html

What about you?

What’s your favorite time saving alias, script, or shell completion? Let us know in the comments!

Hound automatically reviews Ruby, JavaScript, and CoffeeScript code in your GitHub pull requests and comments on style violations. It is free for open source repos and $12/month per private repo.