陈斌彬的技术博客

Stay foolish,stay hungry

Mac-shell 使用 Spark

sparklines for your shell

See? Here’s a graph of your productivity gains after using spark: ▁▂▃▅▇

install

spark is a shell script, so drop it somewhere and make sure it’s added to your $PATH. It’s helpful if you have a super-neat collection of dotfiles, like mine. Or you can use the following one-liner:

sudo sh -c "curl https://raw.githubusercontent.com/holman/spark/master/spark -o /usr/local/bin/spark && chmod +x /usr/local/bin/spark"

If you’re on OS X, spark is also on Homebrew:

brew install spark

usage

Just run spark and pass it a list of numbers (comma-delimited, spaces, whatever you’d like). It’s designed to be used in conjunction with other scripts that can output in that format.

spark 0 30 55 80 33 150

▁▂▃▅▂▇

Invoke help with spark -h.

cooler usage

There’s a lot of stuff you can do.

Number of commits to the github/github Git repository, by author:

› git shortlog -s |
      cut -f1 |
      spark
  ▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▃▁▁▁▁▁▁▁▁▂▁▁▅▁▂▁▁▁▂▁▁▁▁▁▁▁▁▂▁▁▁▁▁▁▁▁▁▁▁▁▁▁

Magnitude of earthquakes over 1.0 in the last 24 hours:

› curl http://earthquake.usgs.gov/earthquakes/catalogs/eqs1day-M1.txt --silent |
  sed '1d' |
  cut -d, -f9 |
  spark
  ▅▆▂▃▂▂▂▅▂▂▅▇▂▂▂▃▆▆▆▅▃▂▂▂▁▂▂▆▁▃▂▂▂▂▃▂▆▂▂▂▁▂▂▃▂▂▃▂▂▃▂▂▁▂▂▅▂▂▆▆▅▃▆

Reference Resource