From b0d6f88a7fbd1e478b0b1892c5832229a99e252f Mon Sep 17 00:00:00 2001 From: Mischa POSLAWSKY Date: Tue, 15 Oct 2019 01:06:59 +0200 Subject: [PATCH] optional width of sparkline lines Output newlines after specified number of records. Keep current single line by default. --- barcat | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/barcat b/barcat index 424bec2..3bc7ca0 100755 --- a/barcat +++ b/barcat @@ -101,7 +101,7 @@ GetOptions(\%opt, }, ) or exit 64; # EX_USAGE -$opt{width} ||= $ENV{COLUMNS} || qx(tput cols) || 80; +$opt{width} ||= $ENV{COLUMNS} || qx(tput cols) || 80 unless $opt{spark}; $opt{color} //= -t *STDOUT; # enable on tty $opt{'graph-format'} //= '-'; $opt{trim} *= $opt{width} / 100 if $opt{trimpct}; @@ -154,6 +154,10 @@ while (defined ($_ = $opt{input} ? shift @{ $opt{input} } : readline)) { and $. % $opt{interval} == 0; } +if ($opt{'zero-missing'}) { + push @values, (0) x 10; +} + $SIG{INT} = 'DEFAULT'; sub color { @@ -243,6 +247,7 @@ while ($nr <= $#lines) { $opt{palette}->[ $rel * ($#{$opt{palette}} - 1) + 1 ]; if ($opt{spark}) { + say '' if $opt{width} and $nr and $nr % $opt{width} == 0; print color($color), $opt{spark}->[ !$val ? 0 : # blank $val == $order[0] ? -1 : # max -- 2.30.0