From 0f0593b3e22f9b4f837a0bf46e214ccfe3f1a8aa Mon Sep 17 00:00:00 2001 From: Erich Eckner Date: Thu, 9 Nov 2017 16:02:05 +0100 Subject: Initial commit --- show-irc-log | 44 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100755 show-irc-log diff --git a/show-irc-log b/show-irc-log new file mode 100755 index 0000000..61c7af2 --- /dev/null +++ b/show-irc-log @@ -0,0 +1,44 @@ +#!/bin/bash + +tmp_dir=$(mktemp -d) +trap 'rm -rf --one-file-system "${tmp_dir}"' EXIT + +find /mnt/archlinux32/irc-logs/#archlinux-ports/ \ + -type f \ + -mtime -2 \ + -name '*-*-*.html' | \ + sort | \ + while read -r s; do + sed -n ' + s|^.* <\([^&]\+\)>|\1 \|| + T + p + ' "${s}" + done | \ + tail -n30 > \ + "${tmp_dir}/input" + +sed 's@|.*$@|@' "${tmp_dir}/input" | \ + { + cols=0 + while read -r s; do + if [ ${#s} -gt ${cols} ]; then + cols=${#s} + fi + done + + sed ' + s@\(|.\{'"$((50-cols))"'\}\)\(.\)@\1\n| \2@ + P + D + ' "${tmp_dir}/input" | \ + sed ' + s/^[^|]*$/| \0/ + :a + /^.\{'"$((cols-1))"'\}|/b + s/|/ |/ + ba + ' + } | \ + tail -n30 | \ + tac -- cgit v1.2.3-54-g00ecf