rake and cap auto complete for bash shell
January 3rd, 2009
I love git and git auto complete bash shell. I get so used to it that I type TAB TAB key even for cap and rake command. I’ve been frustrated so many times to not have auto complete for those commands, so I spent a few time on reading git code and google for it.
And here is my result, a little script to add to your .bashrc and you will have rake and cap completion! And mix of what I read on different code/articles.
My code is available on github: rake_cap_bash_autocomplete You do not need to download the repository, just copy sheel file and check README for installation.
- Copy
rake_cap_bash_autocomplete.shto somewhere (e.g.~/.rake_cap_bash_autocomplete.sh). - Added the following line to your
.bashrc:source ~/.rake_cap_bash_autocomplete.sh
Then, if you test it in an empty rails directory for instance, you will have:
And when you begin to enter a task command:
$ rake TAB TAB
db:abort_if_pending_migrations db:schema:dump doc:plugins rails:freeze:edge test:recent
db:charset db:schema:load doc:rails rails:freeze:gems test:uncommitted
db:collation db:sessions:clear doc:reapp rails:unfreeze test:units
db:create db:sessions:create doc:rerails rails:update time:zones:all
db:create:all db:structure:dump gems rails:update:configs time:zones:local
db:drop db:test:clone gems:build rails:update:javascripts time:zones:us
db:drop:all db:test:clone_structure gems:install rails:update:scripts tmp:cache:clear
db:fixtures:identify db:test:load gems:refresh_specs routes tmp:clear
db:fixtures:load db:test:prepare gems:unpack secret tmp:create
db:migrate db:test:purge gems:unpack:dependencies stats tmp:pids:clear
db:migrate:down db:version log:clear test tmp:sessions:clear
db:migrate:redo doc:app notes test:benchmark tmp:sockets:clear
db:migrate:reset doc:clobber_app notes:custom test:functionals
db:migrate:up doc:clobber_plugins notes:fixme test:integration
db:reset doc:clobber_rails notes:optimize test:plugins
db:rollback doc:guides notes:todo test:profile
If you have more than 128 commands, you will see
$ rake test: TAB TAB
test:benchmark test:functionals test:integration test:plugins test:profile test:recent test:uncommitted test:units
$ rake TAB TAB
Display all 128 possibilities? (y or n)
Same for cap
Enjoy!
2 Responses to “rake and cap auto complete for bash shell”
Sorry, comments are closed for this article.


January 4th, 2009 at 10:02 PM
Nice, thanks for this useful addition.
January 5th, 2009 at 10:26 AM
Really nice, thank you.