sic

personal fork with prompts, tmux splits
git clone git://git.garbash.com/alex/sic
Log | Files | Refs | README | LICENSE

commit fc407b5e1dac24f1e798f099922c50d744dac328
parent 1a15e56489556129a140e9ce4b4113e42c3da02e
Author: alex <alex@garbash.com>
Date:   Fri, 15 Oct 2021 00:04:10 -0400

contrib: Add siccolor and tic to multiplex/colorize sic

siccolor is a simple colorizer for the output of sic(1). tic(1) is a
small wrapper around sic(1) that puts sic(1) in a "write only" 1
line pane of a new tmux session and pops a vertical split above it
that's tailing the logs with siccolor(1).

Benefits of this are:

* No output from messages as you type
* Prompt (-P) extension of sic works well
* No "double viewing" your own messages in the scrollback

tic also uses rlwrap for better input UX.

Diffstat:
Acontrib/siccolor | 51+++++++++++++++++++++++++++++++++++++++++++++++++++
Acontrib/tic | 11+++++++++++
2 files changed, 62 insertions(+), 0 deletions(-)

diff --git a/contrib/siccolor b/contrib/siccolor @@ -0,0 +1,51 @@ +#!/usr/bin/env perl +# siccolor -- colorize sic(1) output +use strict; +use warnings; +use Term::ANSIColor; + +# No black (bg), white (text/msg), bright white, or bright black (time) +my @colors = qw( + green + yellow + blue + magenta + cyan + bright_green + bright_yellow + bright_blue + bright_magenta + bright_cyan +); + +our $i = 0; +our %user_colors; +main(); + +sub main { + while (my $line = <>) { + if ($line =~ m{^([^:]+):\s+(\d\d\d\d-\d\d-\d\d \d\d:\d\d) (<[^>]+>)(.*)}) { + my ($channel, $time, $user, $msg) = ($1, $2, $3, $4); + print get_color($channel) . "$channel"; + print color("bright_black"); + print ": $time "; + print get_color($user) . "$user"; + print color("reset"); + print "$msg\n"; + } else { + # Don't know how to colorize! + print color("bright_black"); + print "$line"; + print color("reset"); + } + } +} + +sub get_color { + my ($val) = @_; + if (!exists $user_colors{$val}) { + $user_colors{$val} = $colors[$i % @colors]; + $i++; + } + return color($user_colors{$val}); +} diff --git a/contrib/tic b/contrib/tic @@ -0,0 +1,11 @@ +#!/bin/sh +# tic -- sic(1) in tmux(1) +# argv is passed to tic! +set -e +mkdir -p "$HOME/.irc" +LOG="$HOME/.irc/$(date +%F).log" +touch "$LOG" + +tmux new-session "tail -f $LOG | siccolor" \; \ + split-pane "rlwrap sic -P $* >>$LOG" \; \ + resize-pane -y 1