Stupid Bash Tricks
Published 6 December 06 by Justin French, 2 comments
So, I’m lazy. Koz says I way overuse Bash aliases, but if I’m going to run rake test one hundred times a day, I’d much rather just type rt. For what it’s worth, I also had rtf for functionals and rtu for units.
But what I really wanted was rtu to run all the unit tests, and rtu foo to run ruby test/unit/foo_test.rb. So good bye bash aliases and hello bash functions!
alias rt='rake test'
rtu() {
if [ "$#" = 1 ]; then
ruby test/unit/$1_test.rb;
else
rake test:units;
fi
}
rtf() {
if [ "$#" = 1 ]; then
ruby test/functional/$1_controller_test.rb;
else
rake test:functionals;
fi
}
Throw that stuff into ~/.bash_profile, open a new Terminal, cd into the RAILS_ROOT for one of your Rails projects and enjoy!
While we were experimenting with all this, Grant and Mark pulled out a few more things from their bag of tricks, so I went and bought yet another domain I’ll never do anything with.
Oh, and the new job is going really well, thanks for asking!