I find myself writing a lot of scripts at work lately that generate
reports on the command line. I was thinking it might be kind of fun
to have a "beach ball" effect on the cursor to let the user know stuff
is happening. For example, I remember install screens for DOS
programs used to have the pipe character "spin" around. Is there a
library that handles this sort of thing?
If you have a reasonable normal shell you could do this:
spinners = ['|', '/', '-', '\\']
printf "%s", spinners
1.upto(1000) do |i|
printf "\b%s", spinners[i % spinners.size]
Works on OSX's bash anyway... I'm sure someone out there can condense that into one line Replace the sleep() call with something that takes awhile to process otherwise all you see is a blur.