mirror of
https://github.com/leahneukirchen/mblaze
synced 2024-11-11 13:10:32 +00:00
mcolor: extract from mless
This commit is contained in:
parent
3d88b3e638
commit
eb4e2c171d
22
mcolor
Executable file
22
mcolor
Executable file
@ -0,0 +1,22 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
# mcolor - colorize rendered mail
|
||||||
|
|
||||||
|
# restart as awk script
|
||||||
|
true + /; exec awk -f "$0"; exit; / {}
|
||||||
|
|
||||||
|
function co(n, c) { e = ENVIRON["MCOLOR_" n]; return e ? e : c }
|
||||||
|
function fg(c, s) { return sprintf("\033[38;5;%03dm%s\033[0m", c, s) }
|
||||||
|
function so(s) { return sprintf("\033[1m%s\033[0m", s) }
|
||||||
|
BEGIN { hdr = 1 }
|
||||||
|
/^$/ { hdr = 0 }
|
||||||
|
/^-- $/ { ftr = 1 }
|
||||||
|
/^--- .* ---/ { print fg(co("SEP",242), $0); ftr = 0; sig = 0; next }
|
||||||
|
/^-----BEGIN .* SIGNATURE-----/ { sig = 1 }
|
||||||
|
hdr && /^From:/ { print so(fg(co("FROM",119), $0)); next }
|
||||||
|
hdr { print fg(co("HEADER",120), $0); next }
|
||||||
|
ftr { print fg(co("FOOTER",244), $0); next }
|
||||||
|
/^-----BEGIN .* MESSAGE-----/ ||
|
||||||
|
/^-----END .* SIGNATURE-----/ { print fg(co("SIG",244), $0); sig = 0; next }
|
||||||
|
sig { print fg(co("SIG",244), $0); next }
|
||||||
|
/^>/ { print fg(co("QUOTE",151), $0); next }
|
||||||
|
{ print }
|
25
mless
25
mless
@ -3,25 +3,6 @@
|
|||||||
|
|
||||||
PATH="${0%/*}:$PATH"
|
PATH="${0%/*}:$PATH"
|
||||||
|
|
||||||
colormsg() {
|
|
||||||
awk '
|
|
||||||
function fg(c, s) { return sprintf("\033[38;5;%03dm%s\033[0m", c, s) }
|
|
||||||
function so(s) { return sprintf("\033[1m%s\033[0m", s) }
|
|
||||||
BEGIN { hdr = 1 }
|
|
||||||
/^$/ { hdr = 0 }
|
|
||||||
/^-- $/ { ftr = 1 }
|
|
||||||
/^--- .* ---/ { print fg(242, $0); ftr = 0; sig = 0; next }
|
|
||||||
/^-----BEGIN .* SIGNATURE-----/ { sig = 1 }
|
|
||||||
hdr && /^From:/ { print so(fg(119, $0)); next }
|
|
||||||
hdr { print fg(120, $0); next }
|
|
||||||
ftr { print fg(244, $0); next }
|
|
||||||
/^-----BEGIN .* MESSAGE-----/ ||
|
|
||||||
/^-----END .* SIGNATURE-----/ { print fg(244, $0); sig = 0; next }
|
|
||||||
sig { print fg(244, $0); next }
|
|
||||||
/^>/ { print fg(151, $0); next }
|
|
||||||
{ print }'
|
|
||||||
}
|
|
||||||
|
|
||||||
colorscan() {
|
colorscan() {
|
||||||
awk '
|
awk '
|
||||||
function fg(c, s) { return sprintf("\033[38;5;%03dm%s\033[0m", c, s) }
|
function fg(c, s) { return sprintf("\033[38;5;%03dm%s\033[0m", c, s) }
|
||||||
@ -51,7 +32,7 @@ if [ "$1" = --filter ]; then
|
|||||||
mshow -A text/html "$2"
|
mshow -A text/html "$2"
|
||||||
else
|
else
|
||||||
mshow "$2"
|
mshow "$2"
|
||||||
fi | colormsg
|
fi | mcolor
|
||||||
else
|
else
|
||||||
mseq -r $2
|
mseq -r $2
|
||||||
echo
|
echo
|
||||||
@ -72,10 +53,10 @@ fi
|
|||||||
case "$0" in
|
case "$0" in
|
||||||
*mnext) set -- +;;
|
*mnext) set -- +;;
|
||||||
*mprev) set -- -;;
|
*mprev) set -- -;;
|
||||||
*) set -- ${1:-.};;
|
*) [ "$#" -eq 1 ] && set -- ${1:-.};;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
if [ "$#" -eq 1 ]; then
|
if [ "$#" -ge 1 ]; then
|
||||||
mseq -C "$1"
|
mseq -C "$1"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user