irb has tab 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 tab 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 tab 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
tab
irb(main):002:0> st.length
=> 16
irb(main):003:0> st.up
tabtab
st.upcase st.upcase! st.upto
irb(main):003:0> st.up