Created
June 28, 2011 17:21
-
-
Save JasonOffutt/1051653 to your computer and use it in GitHub Desktop.
Ruby script to get the RawLine gem included in irb
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/local/bin/ruby -w | |
require 'rubygems' | |
require 'rawline' | |
puts "*** Inline Editor Test Shell ***" | |
puts " * Press CTRL+X to exit" | |
puts " * Press CTRL+C to clear command history" | |
puts " * Press CTRL+D for line-related information" | |
puts "Press CTRL+E to view command history" | |
editor = RawLine::Editor.new | |
editor.bind(:ctrl_c) { editor.clear_history } | |
editor.bind(:ctrl_d) { editor.debug_line } | |
editor.bind(:ctrl_e) { editor.show_history } | |
editor.bind(:ctrl_x) { puts; puts "Exiting..."; exit } | |
editor.completion_proc = lambda do |word| | |
if word | |
['select', 'update', 'delete', 'debug', 'destroy'].find_all { |e| e.match(/^#{Regexp.escape(word)}/) } | |
end | |
end | |
loop do | |
puts "You typed: [#{editor.read("=> ").chomp!}]" | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment