Skip to content

Tabcorp/cli-plot

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

cli-plot

Plot values from stdin directly into your terminal.

NPM License Dependencies

npm install -g cli-plot

Usage

Say you have the following shell script that outputs numbers on stdout:

for i in {1..50}; do
  echo $RANDOM;
  sleep 1;
done

Or the following Node program that outputs a sine wave:

var i = 0;
setInterval(function() {
  var value = Math.sin(i += 0.2);
  process.stdout.write(value + '\n');
}, 100);

You can pipe it into plot to generate a chart right there in your terminal. It will push new values from the right every time they arrive on stdin. Note: input values must be separated by a new line.

node sine.js | plot

Screenshot

Arguments

  • plot -w 100: graph width (in terminal rows)
  • plot -h 10: graph height (in terminal rows)

Advanced usage

  • Printing averages

If the input program outputs numbers very often, the chart will probably move too fast. You can pipe the output into a tool like cli-average.

./random.sh | avg -t 1s | plot
  • Watching the output of another program

One common usage is to run a command at a given rate, and plot its results.

Unfortunately, the watch command also outputs debug info and ANSI escape codes, which doesn't play well with plot. You'll need to use different way to watch that command, for example cli-interval.

interval -t 1s "echo \$RANDOM" | plot
  • Getting values from JSON documents

The easiest way is to use tools like json or jQ.

some_program | json "path.to.value" | plot

About

Plot values from stdin directly into your terminal

Resources

License

Stars

Watchers

Forks

Packages

No packages published