diff --git a/colour-changelog b/colour-changelog new file mode 100755 index 0000000..5f227f7 --- /dev/null +++ b/colour-changelog @@ -0,0 +1,93 @@ +#!/bin/bash +# Version: 0.2.0 +# Original awk code found somewhere on LQ - credit to the original author :) +# Changes copyright (c) 2023: +# Darren 'Tadgy' Austin +# Licensed under the terms of the GNU General Public License version 3. +# +# Best run in a screen or tmux window with activity monitoring turned on, so you get a notification any time the ChangeLog is updated. + +# Defaults. +CHANGELOG_URL="https://ftp.osuosl.org/pub/slackware/slackware64-current/ChangeLog.txt" +# CHANGELOG_URL="https://slackware.uk/slackware/slackware64-current/ChangeLog.txt" +REFRESH_INTERVAL="600" +MAX_LINES="10000000" # Should cover the whole ChangeLog. + +# Colourise at most MAX_LINES of the ChangeLog. +colourise_CL() { + curl -sL "$CHANGELOG_URL" | head -n "$MAX_LINES" | awk ' + /^(Mon|Tue|Wed|Thu|Fri|Sat|Sun) (Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)/ { + print "\033[1;35m"$0"\033[0m"; next + } + /^[^: ]+\/[^: ]+:/ { + status = tolower($2) + colour = "1;33m" + if ((index(status, "added") == 1)) + colour = "1;32m" + else if ((index(status, "removed") == 1)) + colour = "1;31m" + else if ((index(status, "rebuilt") == 1)) + colour = "1;34m" + $1 = "\033["colour$1"\033[0m"; print; next + } + /^\+---+/ { $0 = "" }{ print }' +} + +# Parse command line options. +while (( $# != 0 )); do + case "$1" in + -h|-help|--help) + printf "%s %s %s %s %s\\n" "${0##*/}" "[-l|--lines ]" "[-r|--refresh