-
-
Save dedeibel/219557 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/perl | |
use strict; | |
use warnings; | |
use Chart::Pie; | |
use IO::File; | |
my $pie = Chart::Pie->new(640, 480); | |
my $score; | |
# My script shell isn't zsh so HISTFILE was not set, | |
# let it be specified | |
my $histfile_arg = $ARGV[0]; | |
my $histfile = $ENV{HISTFILE} || $histfile_arg; | |
my $io = new IO::File($histfile); | |
for($io->getlines) { | |
# It seems like I have a different history file format, make the | |
# prefix optional | |
/^(?:\s*\d*:\d*;)?(\w+)/ or next; | |
++$score->{$1}; | |
} | |
my $top = { | |
map { $_ => $score->{$_} } | |
(sort { $score->{$b} <=> $score->{$a} } keys %$score)[0 .. 9] | |
}; | |
$pie->add_dataset(keys %$top); | |
$pie->add_dataset(values %$top); | |
$pie->png("history.png"); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment