-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathirbt.rb
41 lines (33 loc) · 896 Bytes
/
irbt.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# coding: utf-8
# An IRB + mini_readline Test bed
require 'irb'
puts "Starting an IRB console with mini_readline test bed."
if ARGV[0] == 'old'
puts "Using the standard readline gem: #{RbReadline::RB_READLINE_VERSION}"
no_patch = true
ARGV.shift
elsif ARGV[0] == 'local'
require_relative 'lib/mini_readline'
puts "Using mini_readline loaded locally: #{MiniReadline::VERSION}"
no_patch = false
ARGV.shift
else
require 'mini_readline'
puts "Using mini_readline loaded from gem: #{MiniReadline::VERSION}"
no_patch = false
end
puts
#Hack irb to use mini_readline.
unless no_patch
module IRB
class ReadlineInputMethod < InputMethod
#Get a string from mini readline.
def gets
result = MiniReadline.readline(@prompt, true)
HISTORY.push(result) unless result.empty?
@line[@line_no += 1] = result
end
end
end
end
IRB.start