Socket
Socket
Sign inDemoInstall

cli-plot

Package Overview
Dependencies
10
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    cli-plot

Plot values from stdin directly in your terminal


Version published
Weekly downloads
2
increased by100%
Maintainers
1
Install size
207 kB
Created
Weekly downloads
 

Readme

Source

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

FAQs

Last updated on 06 Nov 2014

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc