1 --- /usr/local/bin/mless Tue Oct 25 14:26:22 2022
2 +++ news Fri Nov 25 16:18:08 2022
5 -# mless [MSG] - less(1)-wrapper around mshow
6 +# news - less(1) around mshow for my rss feeds
10 -function co(n, c) { e = ENVIRON["MCOLOR_" n]; return e ? e : c }
11 -function fg(c, s) { return sprintf("\033[38;5;%03dm%s\033[0m", c, s) }
12 -function so(s) { return sprintf("\033[1m%s\033[0m", s) }
13 -/^>/ { print so(fg(co("CUR",119), $0)); next }
14 -/^ *\\_/ { print fg(co("MISS",242), $0); next }
17 +# use a custom mblaze env
18 +mkdir -p ~/.mblaze/news
19 +export MBLAZE=~/.mblaze/news
21 -if [ -n "${NO_COLOR+set}" ]; then
22 - colorscan() { cat -; }
25 if [ "$1" = --filter ]; then
26 if [ "$2" = //scan ]; then
27 - mscan : 2>/dev/null | colorscan
33 $((total - 1))) mscan .-4:.+1 ;;
34 $total) mscan .-5:.+0 ;;
36 - esac 2>/dev/null | colorscan
40 if ! [ -f "$(mseq -r "$2")" ]; then
42 elif [ -f "$HOME/.mless" ]; then
43 export LESSKEY="$HOME/.mless"
46 +MAILFEEDS_DIR="${MAILFEEDS_DIR:-$HOME/Maildir/op/rss}"
47 +mlist -st "$MAILFEEDS_DIR" | mthread -r | mseq -S
50 LESSOPEN="|$0 --filter %s" \
51 less -Ps"mless %f?m (message %i of %m).." -R \
54 78) # N go to next unseen message
55 nu=$(magrep -v -m1 :S .:) && mseq -C "$nu"
57 + 79) # O open the news
58 + url="$(mhdr -h X-Rssgo-Email)"
59 + if [ $? -eq 0 -a -n "$url" ]; then
64 mseq -C "$(mseq .+1: | sed -n '/^[^ <]/{p;q;}')"