Skip to content

Instantly share code, notes, and snippets.

@aycabta
Created November 1, 2014 08:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save aycabta/ad0a1cc317e74939f348 to your computer and use it in GitHub Desktop.
Save aycabta/ad0a1cc317e74939f348 to your computer and use it in GitHub Desktop.
#!/usr/bin/env ruby
require 'optparse'
run_interval_milli_second = 1000
opt = OptionParser.new
opt.on('-i VAL') { |v| run_interval_milli_second = v.to_i }
opt.parse!(ARGV)
str = ARGV.empty? ? ARGF.read : ARGV.join(' ')
str.chomp.split(/(?=.)/).inject do |run_str, c|
print "#{run_str}\r"
sleep run_interval_milli_second / str.length / 1000.0
run_str + c
end
print "#{str}\n"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment