diff options
author | Christian Neukirchen <chneukirchen@gmail.com> | 2016-07-28 23:10:45 +0200 |
---|---|---|
committer | Christian Neukirchen <chneukirchen@gmail.com> | 2016-07-28 23:10:45 +0200 |
commit | aa228ddd43fd86b440040d4ecb09b80c2efec517 (patch) | |
tree | 47a0756d0c74bedd2170460480d0182abb9bc4f9 | |
parent | 122e0f4426831ceb222ab2c3f7919e1721b30ceb (diff) | |
download | mblaze-aa228ddd43fd86b440040d4ecb09b80c2efec517.tar.gz mblaze-aa228ddd43fd86b440040d4ecb09b80c2efec517.tar.xz mblaze-aa228ddd43fd86b440040d4ecb09b80c2efec517.zip |
mless: simplify
We always show the full sequence now, and just jump to the passed message.
-rw-r--r-- | man/mless.1 | 7 | ||||
-rwxr-xr-x | mless | 29 |
2 files changed, 19 insertions, 17 deletions
diff --git a/man/mless.1 b/man/mless.1 index 753f144..8ac88e1 100644 --- a/man/mless.1 +++ b/man/mless.1 @@ -6,14 +6,17 @@ .Nd interactive wrapper around mshow .Sh SYNOPSIS .Nm -.Op Ar msgs\ ... +.Op Ar msg .Sh DESCRIPTION .Nm runs .Xr less 1 on the output of .Xr mshow 1 -for the given messages. +for the current sequence. +Display starts with the current message, or +.Ar msg +if passed. See .Xr mmsg 7 for the message argument syntax. diff --git a/mless b/mless index 2feaf03..03f41a1 100755 --- a/mless +++ b/mless @@ -1,5 +1,5 @@ #!/bin/sh -# mless RANGES... - less(1)-wrapper around mshow +# mless [MSG] - less(1)-wrapper around mshow PATH="${0%/*}:$PATH" @@ -31,10 +31,6 @@ function so(s) { return sprintf("\033[1m%s\033[0m", s) } { print }' } -mnums() { - mscan "$@" 2>/dev/null | awk '$2 ~ /^[0-9]*$/ { print $2 }' -} - if [ "$1" = --filter ]; then if [ "$2" = //scan ]; then mscan : 2>/dev/null | colorscan @@ -45,7 +41,7 @@ if [ "$1" = --filter ]; then mscan .-2:.+3 2>/dev/null | colorscan echo - if ! [ -f $(mseq "$2") ]; then + if ! [ -f "$(mseq -r "$2")" ]; then mseq "$2" exit fi @@ -54,23 +50,26 @@ if [ "$1" = --filter ]; then exit $? fi -scantab= if [ "$#" -eq 0 ] && ! [ -t 0 ]; then mseq -S >/dev/null set -- : - scantab=//scan fi if ! [ -t 1 ]; then - exec mseq "$@" + exec mseq : fi case "$0" in - *next*) d=1;; - *prev*) d=-1;; - *) d=0;; + *mnext) set -- +;; + *mprev) set -- -;; + *) set -- ${1:-.};; 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 :) |