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 do I get auto-completion in IRB?
当我使用Merb的内置控制台时,我将获得类似于标准bash提示符的tab自动完成。我发现这很有用,并希望在非merb IRB会话中启用它。如何在IRB中自动完成?
3 个解决方案
#1
58
Just drop require 'irb/completion'
in your irbrc.
在你的irbrc中只需要“irb/完成”。
If that doesn't work try bond, http://tagaholic.me/bond/:
如果这行不通,可以试试bond, http://tagaholic.me/bond/:
require 'bond'; require 'bond/completion'
Bond not only improves irb's completion, http://tagaholic.me/2009/07/22/better-irb-completion-with-bond.html, but also offers an easy dsl for making custom autocompletions.
邦德不仅提高了irb的完成度,http://tagaholic.me/2009/07/22/better irb- completionwith- Bond。它还提供了一个简单的dsl,用于定制自动完成。
#2
17
This is just repeating the information on Cody Caughlan's comment above so it is easier to find:
这只是重复Cody Caughlan的评论,这样更容易找到:
either require 'irb/completion'
or add the following to ~/.irbrc
要么要求“irb/completion”,要么向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
#3
2
This is what worked for me on Mac OS 10.11.5. using rvm. Do the following :
这就是我在Mac OS 10.11.5中的表现。使用区。执行以下操作:
sudo gem install bond
- sudo gem安装债券
- Create the file
.irbrc
in your home directory.vi ~/.irbrc
- 在主目录中创建文件。irbrc。六世~ / .irbrc
-
Add the following lines in the
.irbrc
filerequire 'bond' Bond.start
在.irbrc文件中添加以下行需要'bond' .start
-
Save and close the file
保存并关闭文件
- Open
irb
and usetab
key to autocomplete - 打开irb并使用tab键自动完成
#1
58
Just drop require 'irb/completion'
in your irbrc.
在你的irbrc中只需要“irb/完成”。
If that doesn't work try bond, http://tagaholic.me/bond/:
如果这行不通,可以试试bond, http://tagaholic.me/bond/:
require 'bond'; require 'bond/completion'
Bond not only improves irb's completion, http://tagaholic.me/2009/07/22/better-irb-completion-with-bond.html, but also offers an easy dsl for making custom autocompletions.
邦德不仅提高了irb的完成度,http://tagaholic.me/2009/07/22/better irb- completionwith- Bond。它还提供了一个简单的dsl,用于定制自动完成。
#2
17
This is just repeating the information on Cody Caughlan's comment above so it is easier to find:
这只是重复Cody Caughlan的评论,这样更容易找到:
either require 'irb/completion'
or add the following to ~/.irbrc
要么要求“irb/completion”,要么向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
#3
2
This is what worked for me on Mac OS 10.11.5. using rvm. Do the following :
这就是我在Mac OS 10.11.5中的表现。使用区。执行以下操作:
sudo gem install bond
- sudo gem安装债券
- Create the file
.irbrc
in your home directory.vi ~/.irbrc
- 在主目录中创建文件。irbrc。六世~ / .irbrc
-
Add the following lines in the
.irbrc
filerequire 'bond' Bond.start
在.irbrc文件中添加以下行需要'bond' .start
-
Save and close the file
保存并关闭文件
- Open
irb
and usetab
key to autocomplete - 打开irb并使用tab键自动完成