irb has completion support, you need to activate this by requiring ‘irb/completion’. You can load it when you invoke irb from the command line:
% irb -r irb/completion
Or you can load the completion library when irb is running:
% irb(main):005:0> require 'irb/completion'
If you often use completion then:
Linux users: Can create an alias in .bashrc by following these steps:
- % vi ~/.bashrc
- add
alias irbtc="irb -r 'irb/completion'"
- % source ~/.bashrc
Windows Users: Can create a file named irbtc.bat in your windows\system32 folder as irb -r "irb/completion"
the file content.
<
Now you can run irb with completion support by:
% irbtc
Example:
% irbtc
irb(main):001:0> st="this is a string"
=> "this is a string"
irb(main):002:0> st.len
irb(main):002:0> st.length
=> 16
irb(main):003:0> st.up
st.upcase st.upcase! st.upto
irb(main):003:0> st.up
or:
require 'irb/completion'
in your ~/.ircrc file
sorry, typo, that should of course be:
~/.irbrc
..and not:
~/.ircrc
how about just adding the require line to your .irbrc? No need to fuss with aliases or bashrc.
While you’re there, try requiring ‘pp’ for pretty printing, and maybe include this code for persistent command line history across irb sessions: http://wiki.rubygarden.org/Ruby/page/show/Irb/TipsAndTricks
I was getting some strange problem while starting webrick after adding require line in .irbrc file.
[…] A fast & effective way for having auto-completion in irb (with some limitation) via web on rails […]