From: Michael Fellinger Date: 2008-11-07T09:06:54+09:00 Subject: Re: Showing a spinner ? On Wed, Nov 5, 2008 at 1:22 AM, Rodrigo Bermejo wrote: > Aldric Giacomoni wrote: >> How do I show a spinner on the command line interface when a ruby script >> is working? I sometimes write things that take a while, and I know I get >> impatient when all I see a blinking cursor :) >> A spinner has \ | / - all in one spot so it looks like a spinning wheel. >> >> Thanks! >> >> --Aldric > > Here is the idea ..you can make it better.. > > a=["-","\\","|","/"] > n=0 > while 1 do > print a[n % 4] > print "\b" > n+=1 > sleep 0.1 > puts "..#{n}." if (n % 50==0) > end Just had the same thing lying around to keep ssh alive, not much in terms of progress though See http://0xcc.net/ruby-progressbar/index.html.en for a full lib that handles this problem sigma ~prog/ruby % cat spinner.rb a = %w[ | / - \\ ] $stdout.sync = true loop do print a.unshift(a.pop).last sleep 0.1 print "\b" end