# Command Line Apps "Beach ball"

**URL:** <https://www.ruby-forum.com/t/command-line-apps-beach-ball/148875>\
**Category:** Rails\
**Created:** [September 17, 2008, 10:34pm UTC](https://www.ruby-forum.com/t/command-line-apps-beach-ball/148875 "2008-09-17T22:34:20Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![sjames](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/c57346/32.png) [@sjames](https://www.ruby-forum.com/u/sjames)\
**Post date:** [September 17, 2008, 10:34pm UTC](https://www.ruby-forum.com/t/command-line-apps-beach-ball/148875/1 "2008-09-17T22:34:20Z")

</div>

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?

James

---

<div class="post-metadata">

**Author:** ![sjames](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/c57346/32.png) [@sjames](https://www.ruby-forum.com/u/sjames)\
**Post date:** [September 17, 2008, 11:59pm UTC](https://www.ruby-forum.com/t/command-line-apps-beach-ball/148875/2 "2008-09-17T23:59:20Z")

</div>

> 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[0]  
STDOUT.flush  
1.upto(1000) do |i|  
printf “\b%s”, spinners[i % spinners.size]  
STDOUT.flush  
sleep(0.1)  
end

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.

-philip
