#!/bin/bash # weewatch - mutiplex all weechat logs to one stream, as seen in sic irc client # usage: # weewatch; inotifywait --quiet --monitor --event modify ~/.weechat/logs/ | while read; do weewatch; done # tmp file old="/tmp/weewatchold.txt"; new="/tmp/weewatchnew.txt" touch "$old" "$new" || exit # action cd ~/.weechat/logs/ || exit # main main () { for log in *.weechatlog; do baseext="${log##*/}" base="${baseext%.*}" #echo "$base" # lets replace cat with tail for performance resons tail -n 100 "$log" | while read -r date clock restofline; do echo "$date $clock (${base##*.}) $restofline" done done } # cover the non-interactive use as well? cols="$(tput cols)" || cols="85" lines="$(tput lines)" || lines="25" # run main | grep -v '▬▬▶\|◀▬▬\|-->\|<--' | sort | cut -d' ' -f2- > "$new" # print diff --old-line-format=' %L' --new-line-format='+%L' --unchanged-line-format=' %L' \ "$old" "$new" | sed 's/\t/: /g' | fold -s -w "$cols" | tail -n $(( lines - 1 )) #cp "$new" "$old" { sleep 10; cp "$new" "$old"; } & # ^ Not sure