Arturo Herrero

sparky

I have started to hack on an idea I had last week. The idea is to display statistics about version control systems in a Unix shell and I also want to improve my command line fu.

Before start, I remembered spark, an awesome project that generates sparklines for a set of data, so I interested in trying an alternative Groovy implementation and have fun.

▁▂▃▅▂▇ in your shell. Groovy flavoured!

My project is sparky. It’s a Groovy script that lets you graph tiny sparkline graphs from your command line.

sparky takes a list of numbers (comma-delimited, spaces, whatever you’d like) and then prints a sparkline out of it. It’s designed to be used in conjunction with other scripts that can output in that format.

Examples:

$ sparky 1 5 22 13 53
▁▁▃▂▇

$ sparky 0,30,55,80,33,150
▁▂▃▅▂▇

$ echo 9 13 5 17 1 | sparky
▄▆▂█▁

Cooler usage

There’s a lot of stuff you can do.

Number of commits to the groovy-core git repository, by author:

$ git shortlog -s |
> awk '{print $1}' |
> sparky
▁▁▁▁▁▁▁▁▁▁▁▃▁▁▁▁▁▁▁▁▁▁▁▁▂▁▁▄▁▁▁▁▁▁▁▅▁▁▁▁▁▁▁▁▁▁▁▁█▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁

Code visualization. The number of characters of sparky itself, by line, ignoring empty lines:

$ awk '{ print length($0) }' sparky |
> grep -v ^0$ |
> sparky
▂▂▁▁▃▁▃▂▃▃▃▂▁▁▂▄▁▄▅▅█▅▂▁▁▃▃▅▁▁▃▂▁▁▇▃▁

Try it!

June 17, 2012 | @ArturoHerrero