mless: simplify

We always show the full sequence now, and just jump to the passed message.
pull/2/head
Christian Neukirchen 8 years ago
parent 122e0f4426
commit aa228ddd43

@ -6,14 +6,17 @@
.Nd interactive wrapper around mshow .Nd interactive wrapper around mshow
.Sh SYNOPSIS .Sh SYNOPSIS
.Nm .Nm
.Op Ar msgs\ ... .Op Ar msg
.Sh DESCRIPTION .Sh DESCRIPTION
.Nm .Nm
runs runs
.Xr less 1 .Xr less 1
on the output of on the output of
.Xr mshow 1 .Xr mshow 1
for the given messages. for the current sequence.
Display starts with the current message, or
.Ar msg
if passed.
See See
.Xr mmsg 7 .Xr mmsg 7
for the message argument syntax. for the message argument syntax.

29
mless

@ -1,5 +1,5 @@
#!/bin/sh #!/bin/sh
# mless RANGES... - less(1)-wrapper around mshow # mless [MSG] - less(1)-wrapper around mshow
PATH="${0%/*}:$PATH" PATH="${0%/*}:$PATH"
@ -31,10 +31,6 @@ function so(s) { return sprintf("\033[1m%s\033[0m", s) }
{ print }' { print }'
} }
mnums() {
mscan "$@" 2>/dev/null | awk '$2 ~ /^[0-9]*$/ { print $2 }'
}
if [ "$1" = --filter ]; then if [ "$1" = --filter ]; then
if [ "$2" = //scan ]; then if [ "$2" = //scan ]; then
mscan : 2>/dev/null | colorscan mscan : 2>/dev/null | colorscan
@ -45,7 +41,7 @@ if [ "$1" = --filter ]; then
mscan .-2:.+3 2>/dev/null | colorscan mscan .-2:.+3 2>/dev/null | colorscan
echo echo
if ! [ -f $(mseq "$2") ]; then if ! [ -f "$(mseq -r "$2")" ]; then
mseq "$2" mseq "$2"
exit exit
fi fi
@ -54,23 +50,26 @@ if [ "$1" = --filter ]; then
exit $? exit $?
fi fi
scantab=
if [ "$#" -eq 0 ] && ! [ -t 0 ]; then if [ "$#" -eq 0 ] && ! [ -t 0 ]; then
mseq -S >/dev/null mseq -S >/dev/null
set -- : set -- :
scantab=//scan
fi fi
if ! [ -t 1 ]; then if ! [ -t 1 ]; then
exec mseq "$@" exec mseq :
fi fi
case "$0" in case "$0" in
*next*) d=1;; *mnext) set -- +;;
*prev*) d=-1;; *mprev) set -- -;;
*) d=0;; *) set -- ${1:-.};;
esac esac
curcmd=$(mnums "$@" |
awk -v cur=$(mseq -n .) -v d=$d '$1 == cur {print "+" FNR+d ":x"; quit}')
LESSOPEN="|$0 --filter %s" exec less -Ps"mless %f?m (message %i of %m).." -R $curcmd $scantab $(mnums "$@") if [ "$#" -eq 1 ]; then
mseq -C "$1"
fi
nl="
"
LESSOPEN="|$0 --filter %s" exec less -Ps"mless %f?m (message %i of %m).." -R \
"+:e $(mseq -n .)$nl" //scan $(mseq -n :)

Loading…
Cancel
Save