How to enable autocomplete in Ruby IRB

When I use the built-in Merb console, I get automatic tab completion, similar to the standard bash hint. I find this useful and would like to include it in non-working IRB sessions. How to get auto complete in IRB?

+43
ruby tab-completion irb
Sep 05 '09 at 0:30
source share
3 answers

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

If this does not work, try the link, http://tagaholic.me/bond/ :

  require 'bond'; require 'bond/completion' 

Bond not only improves the completion of irb, http://tagaholic.me/2009/07/22/better-irb-completion-with-bond.html , but also offers a simple dsl to create custom autocomplete.

+50
Sep 05 '09 at 5:14
source share

This simply repeats the Cody Cogl commentary above, so it’s easier to find:

either require 'irb/completion' , or add the following to ~/.irbrc

 IRB.conf[:AUTO_INDENT] = true IRB.conf[:USE_READLINE] = true IRB.conf[:LOAD_MODULES] = [] unless IRB.conf.key?(:LOAD_MODULES) unless IRB.conf[:LOAD_MODULES].include?('irb/completion') IRB.conf[:LOAD_MODULES] << 'irb/completion' end 
+15
Sep 05 '09 at 1:58
source share

This is what worked for me on Mac OS 10.11.5. using rvm. Follow these steps:

  • sudo gem install bond
  • Create the .irbrc file in your home directory. vi ~/.irbrc
  • Add the following lines to the .irbrc require 'bond' Bond.start

  • Save and close the file

  • Open irb and use tab key to autocomplete
+1
Jul 20 '16 at 12:24
source share



All Articles