blob: 0f02078870f7cf2d517d0774931adf9ad5e5d6a4 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
|
#!/bin/sh
# mless RANGES... - less(1)-wrapper around mshow
PATH="${0%/*}:$PATH"
if [ "$1" = --filter ]; then
mshow "$2" | 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 }
hdr && /^From:/ { print so(fg(119, $0)); next }
hdr { print fg(120, $0); next }
/^--- .* ---/ { print fg(242, $0); next }
/^>/ { print fg(151, $0); next }
{ print }'
exit $?
fi
curcmd=$(mseq -n "$@" |
awk -v cur=$(mseq -n .) '$1 == cur {print "+" FNR ":x"; quit}')
LESSOPEN="|$0 --filter %s" exec less -R $curcmd $(mseq -n "$@")
|