]> snippets.scripts.mit.edu Git - Scripts/git/.git/blame - barnowl/personal-colors.pl
kdo: Upstream krb5 now supports kswitch
[Scripts/git/.git] / barnowl / personal-colors.pl
CommitLineData
44f8db5d
GT
1# Automatically colors personals by hashing the username. Inspired by geofft's
2# .bashrc. Needs a lot of tweaking to make perfect...
3#
4# To use:
5# :perl do '/mit/snippets/barnowl/personal-colors.pl'
6# :view -s colors
7
8package BarnOwl::Style::Colors;
9our @ISA=qw(BarnOwl::Style::Default);
10use Digest::MD5;
11
12sub description {"Colors for personals";}
13
14sub format_chat {
15 my $self = shift;
16 my $m = shift;
17 my $body = $self->indent_body($m);
18 if ($m->is_personal) {
19 my @colors = qw{red green blue yellow magenta cyan};
20 my $hash = ord Digest::MD5::md5(($m->direction eq "out") ? $m->pretty_recipient : $m->pretty_sender);
21 $body = '@[@color(' . $colors[$hash % scalar @colors] . ")$body]";
22 }
23 return $self->chat_header($m) . "\n". $body;
24}
25
26BarnOwl::create_style("colors", "BarnOwl::Style::Colors");
27
281;