Tab completion in irb
October 7, 2006
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
Entry Filed under: Ruby. .
8 Comments Add your own
Leave a Comment
Some HTML allowed:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <pre> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>
Trackback this post | Subscribe to the comments via RSS Feed







1.
ruby licious | October 7, 2006 at 5:14 pm
or:
require 'irb/completion'in your ~/.ircrc file
2.
ruby licious | October 7, 2006 at 5:17 pm
sorry, typo, that should of course be:
~/.irbrc
..and not:
~/.ircrc
3.
Devin Ben-Hur | October 8, 2006 at 5:53 pm
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
4.
Akhil Bansal | October 9, 2006 at 5:36 am
I was getting some strange problem while starting webrick after adding require line in .irbrc file.
5. Auto-Completion in Irb | October 17, 2006 at 1:14 pm
[...] A fast & effective way for having auto-completion in irb (with some limitation) via web on rails [...]
6. Australian job | January 20, 2007 at 8:20 pm
Australian job
Well… Nice blog!
7.
freeeeringtones | August 18, 2007 at 2:37 am
popular free ringtones
http://www.thehotstop.info
signature…
8. reality » Blog Archive » 在 irb 中使用 auto completion | January 31, 2008 at 4:41 pm
[...] Reference :Tab completion in irb [...]