Posted by
jp on Oct 26th, 2009 in
blog,
ruby,
tech |
0 comments
I’ve always tried to make my scripts’ responses prettier and less crowded, and I came across something like the following piece of code, that helped me a lot lately
#!/usr/bin/env ruby
STDOUT.sync = true
bars = ['/','-','\\','|']
i=1
while i do
print "\rrunning #{bars[i%4]}"
i += 1
sleep 1
end
trap("INT") {
print "\n\n"
exit
}
If you like to see updates without flooding your terminal screen, this is...