Skip to content

Instantly share code, notes, and snippets.

@Freaky
Created January 2, 2019 15:55
Show Gist options
  • Save Freaky/2735f7bc14dd9c832b49911da29e6834 to your computer and use it in GitHub Desktop.
Save Freaky/2735f7bc14dd9c832b49911da29e6834 to your computer and use it in GitHub Desktop.
Print crap before readline
#!/usr/bin/env ruby
require 'readline'
run = true
puts
worker = Thread.new do
i = 0
while run
STDOUT.print("\e[s\r\e[A\e[KMoo moo baa #{i += 1}\n\e[u");
sleep 1
end
end
out = Readline.readline("Moo: ")
run = false
worker.join
puts "Read: #{out.inspect}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment