I don't know if IRB has this feature on other systems, but the IRB ruby2.1.2 on Ubuntu defaults to no code auto-completion, which is a little inconvenient. In fact, plus is also very simple, is in IRB add a module: Require ' irb/ Completion ', but we're not going to have to hit a line of code every time, where's kiss and dry?
The simplest way to do this once and for all is to add the code that the IRB runtime needs to execute in the ~/.IRBRC. You have to ask me how I know. irbrc file path you can see through irb.rc_file. There is also a more advanced auto-completion function on the Internet. This includes adding syntax highlighting, and so on. The author's method is to download and install the wirble gem:sudo gem install wirble, and then add the following code to the. Irbrc file:
Require "RubyGems" require "wirble" wirble.initwirble.colorizeirb.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
Interested children's shoes can try it yourself.
The ability for IRB to automate code completion under Linux