Created
May 25, 2011 01:45
-
-
Save havenwood/990164 to your computer and use it in GitHub Desktop.
This file contains 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
require 'readline' | |
# Empty and dup are BAD. | |
# 1. Read line and append to history | |
# 2. Quick Break on nil | |
# 3. Remove from history if empty or dup | |
def readline_lineread | |
line = Readline.readline('> ', true) | |
return nil if line.nil? | |
if line =~ /^\s*$/ or Readline::HISTORY.to_a[-2] == line | |
Readline::HISTORY.pop | |
end | |
line | |
end | |
# Debug | |
while line = readline_lineread | |
p line | |
p Readline::HISTORY.to_a | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment