Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to enable auto completion in Ruby's IRB

When I use Merb's built in console, I get tab auto-completion similar to a standard bash prompt. I find this useful and would like to enable it in non-merb IRB sessions. How do I get auto-completion in IRB?

like image 259
John F. Miller Avatar asked Sep 05 '09 00:09

John F. Miller


People also ask

How do I use IRB in Ruby?

To use it, you launch the irb executable and type your Ruby code at the prompt. IRB evaluates the code you type and displays the results. IRB gives you access to all of Ruby's built-in features, as well as any libraries or gems you've installed.

What is Irbrc?

The . irbrc file is nothing else than a Ruby file that gets evaluated whenever we start the console with irb or rails c . We can place it in a home directory ( ~/. irbrc ) or in the project directory (to scope it per project). But only one of these files will take effect, and the global one has precedence.


1 Answers

Just drop require 'irb/completion' in your irbrc.

If that doesn't work try bond, http://tagaholic.me/bond/:

   require 'bond'; require 'bond/completion' 

Bond not only improves irb's completion, http://tagaholic.me/2009/07/22/better-irb-completion-with-bond.html, but also offers an easy dsl for making custom autocompletions.

like image 193
cldwalker Avatar answered Sep 28 '22 19:09

cldwalker