How to enable auto completion in Ruby's IRB
Solution 1
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.
Solution 2
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] = 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
Solution 3
This is what worked for me on Mac OS 10.11.5. using rvm. Do the following :
sudo gem install bond
- Create the file
.irbrc
in your home directory.vi ~/.irbrc
Add the following lines in the
.irbrc
filerequire 'bond' Bond.start
Save and close the file
- Open
irb
and usetab
key to autocomplete
John F. Miller
Currently hacking Haskell in my spare time. I've also done Ruby in the past. Self-taught enthusiast programmer who enjoys pushing the edges: Current Project: Writing a language using Haskell and LLVM Writing an economy simulation game engine
Updated on June 07, 2022Comments
-
John F. Miller almost 2 years
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?