dot

packages and services management
Log | Files | Refs | README

commit 088ce686ba791367750cd403c9f7eec673c7fddc
parent d7d4fb7b02ad813e7f39478761e6851a1c218b10
Author: Josuah Demangeon <josuah.demangeon@gandi.net>
Date:   Tue, 25 Jul 2017 22:35:29 +0200

bin/plot: plot in plain text with ':' and '.'

Diffstat:
Abin/plot | 22++++++++++++++++++++++
1 file changed, 22 insertions(+), 0 deletions(-)

diff --git a/bin/plot b/bin/plot @@ -0,0 +1,22 @@ +awk ' +{ + maxcol = split($0, dots) + maxrow = 0 + + # find the max + for (col = 0; col < maxcol; col++) + if (maxrow < dots[col + 1]) + maxrow = dots[col + 1] + + for (col = 0; col < maxcol; col++) + for (row = maxrow + maxrow % 2; row > 0; row--) + grid[row "-" col] = dots[col + 1] < row ? 0 : 1 + + for (r = maxrow + maxrow % 2; r > 0; r -= 2) { + for (c = 0; c < col; c++) + printf grid[r "-" c] && grid[r + 1 "-" c] ? ":" : \ + grid[r "-" c] && !grid[r + 1 "-" c] ? "." : " " + print "" + } +} +' "$@"