Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 24 Feb 2011 20:17:21 +0000 (UTC)
From:      Thorsten Glaser <tg@mirbsd.org>
To:        freebsd-questions@freebsd.org
Subject:   Re: variable line-display pager?
Message-ID:  <loom.20110224T211246-830@post.gmane.org>
References:  <20110219233736.GA20393@thought.org>

next in thread | previous in thread | raw e-mail | index | archive | help
Gary Kline <kline <at> thought.org> writes:

> For instance, say that my xterm/console/"Konsole" is 80x53 lines.
> My text file is around 200 lines long and I want to use more or less
> or some GUI pager to display only 15 lines at one time.  Tapping the 
> space bar would display another 15 lines and so on until EOF.  Is

mksh-current from CVS comes with a shell function called “smores”
which implements “something like” more(1) in (Korn) Shell. You’ll
need to press Return though, not Space, to go on.

If you replace the word LINES with 15 you get the behaviour you
want. The source is here (just look for “smores”):
https://www.mirbsd.org/cvs.cgi/src/bin/mksh/dot.mkshrc?rev=HEAD

If your mksh is “too old”, you’ll need to replace
		llen=${%line}
		(( llen == -1 )) && llen=${#line}
with
		llen=${#line}
(since “${%foo} = width of $foo in screen columns” got added
only recently, but “${#foo} = size of $foo in octets” has been
there for a while)

Note that, if you run smores as shell function, it’s aware of
whether your current locale is UTF-8 or not (use “set -U” to
enable UTF-8 mode, “set +U” to disable it, if you don’t want
that). This, again, only affects ${%line} calculation.

HTH & HAND,
//mirabilos
-- 
Yay for having to rewrite other people's Bash scripts because bash
suddenly stopped supporting the bash extensions they make use of
        -- Tonnerre Lombard in #nosec




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?loom.20110224T211246-830>