How to enable auto completion in Ruby's IRB

前端 未结 3 512
礼貌的吻别
礼貌的吻别 2021-01-29 23:41

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

3条回答
  •  暗喜
    暗喜 (楼主)
    2021-01-30 00:06

    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 
    

提交回复
热议问题