How to enable auto completion in Ruby's IRB How to enable auto completion in Ruby's IRB ruby ruby

How to enable auto completion in Ruby's IRB


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.


This is just repeating the information on Cody Caughlan's comment above so it is easier to find:

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

IRB.conf[:AUTO_INDENT] = trueIRB.conf[:USE_READLINE] = trueIRB.conf[:LOAD_MODULES] = [] unless IRB.conf.key?(:LOAD_MODULES)unless IRB.conf[:LOAD_MODULES].include?('irb/completion')  IRB.conf[:LOAD_MODULES] << 'irb/completion'end 


This is what worked for me on Mac OS 10.11.5. using rvm. Do the following :

  1. sudo gem install bond
  2. Create the file .irbrc in your home directory. vi ~/.irbrc
  3. Add the following lines in the .irbrc filerequire 'bond' Bond.start

  4. Save and close the file

  5. Open irb and use tab key to autocomplete