[comp.unix.questions] Need to make "less" do a particular thing "right"

phil@ux1.cso.uiuc.edu (Phil Howard KA9WGN) (02/21/91)

pfalstad@phoenix.Princeton.EDU (Paul Falstad) writes:

>man less reveals that...

>man lesskey reveals that...

I want to make the "less" command NOT switch over to the alterate screen.
This is so that when I press "q" to quit from less, it will NOT switch
back to the primary screen on me.  I want to have the data I am looking
at in less be left on the screen, my shell prompt come up, and let me
type my next command while still looking at what less was showing me.

I did RTFM and could not find this.
-- 

--Phil Howard, KA9WGN-- | Individual CHOICE is fundamental to a free society
<phil@ux1.cso.uiuc.edu> | no matter what the particular issue is all about.

pfalstad@phoenix.Princeton.EDU (Paul Falstad) (02/21/91)

phil@ux1.cso.uiuc.edu (Phil Howard KA9WGN) wrote:
>I want to make the "less" command NOT switch over to the alterate screen.
>I did RTFM and could not find this.

I hate this behavior too.  I don't think the FM tells how to get rid of
it; I checked the source and it looks like there's no option for it.
Here's the hack I use; works great for me.

---cut here---
#! /bin/sh
#
# a front end for less that does not make xterm swap screens
#
TERMCAP=`echo $TERMCAP | sed 's/:ti=[^:]*:te=[^:]*:/:ti=:te=:/'` \
   /usr/princeton/bin/less "$@"
---cut here---

This could be done more efficiently, obviously.  I have an environment
variable called LESSTERM that I set in my .zlogin that has the ti and
te entries removed; then I alias less to
'TERMCAP="$LESSTERM" /usr/local/bin/less'.  With a csh-like shell
you could do '(setenv TERMCAP LESSTERM; /usr/local/bin/less)'.
I don't just remove ti and te from TERMCAP because I want vi to
swap screens.

--
  Paul Falstad, pfalstad@phoenix.princeton.edu PLink:HYPNOS GEnie:P.FALSTAD
  I think there should be more race prejudice.  <slap> LESS race prejudice.
     Princeton University apologizes for the content of this article.

wht@n4hgf.Mt-Park.GA.US (Warren Tucker) (02/22/91)

In article <1991Feb20.210427.26089@ux1.cso.uiuc.edu> phil@ux1.cso.uiuc.edu (Phil Howard KA9WGN) writes:
>I want to make the "less" command NOT switch over to the alterate screen.
>This is so that when I press "q" to quit from less, it will NOT switch
The terminal initialization string (termcap "ti") and deinit string (termcap
"te") are sent by the following code in screen.c:

/*
 * Initialize terminal
 */
	public void
init()
{
	tputs(sc_init, sc_height, putchr);
}

/*
 * Deinitialize terminal
 */
	public void
deinit()
{
	tputs(sc_deinit, sc_height, putchr);
}

I did not see the previous articles in this thread, but if you are
using xterm, the titeInhibit resource controls whether or not xterm
honors the ti and te sequences.
 
-----------------------------------------------------------------------
Warren Tucker, TuckerWare   gatech!n4hgf!wht or wht@n4hgf.Mt-Park.GA.US
Many [Nobel physics] prizes  have been given  to people for  telling us
the universe is not as simple as we thought it was. -Stephen Hawking in
A Brief History of Time     In computing, there are no such prizes. -me

mark@hsi86.hsi.com (Mark Sicignano) (02/22/91)

In article <6451@idunno.Princeton.EDU> pfalstad@phoenix.Princeton.EDU (Paul Falstad) writes:
|phil@ux1.cso.uiuc.edu (Phil Howard KA9WGN) wrote:
|>I want to make the "less" command NOT switch over to the alterate screen.
|>I did RTFM and could not find this.
|
|I hate this behavior too.  I don't think the FM tells how to get rid of
|it; I checked the source and it looks like there's no option for it.
|Here's the hack I use; works great for me.
|...

At least on our system, we can do a "man xterm" and look at what it
has to say for titeInhibit (class TiteInhibit).

-mark
-- 
Mark Sicignano                                  ...!uunet!hsi!mark
3M Health Information Systems                   mark@hsi.com

greywolf@unisoft.UUCP (The Grey Wolf) (02/26/91)

In article <1991Feb20.210427.26089@ux1.cso.uiuc.edu> phil@ux1.cso.uiuc.edu (Phil Howard KA9WGN) writes:
>pfalstad@phoenix.Princeton.EDU (Paul Falstad) writes:
>
>>man less reveals that...
>
>>man lesskey reveals that...
>
>I want to make the "less" command NOT switch over to the alterate screen.
>This is so that when I press "q" to quit from less, it will NOT switch
>back to the primary screen on me.  I want to have the data I am looking
>at in less be left on the screen, my shell prompt come up, and let me
>type my next command while still looking at what less was showing me.
>
>I did RTFM and could not find this.

I would say that you have some sort of souped-up termcap that loves to
use the memory-page capability of your terminal.  I would suggest that you
use a slightly less sophisticated version of your termcap, or get your
sysadmin to modify the termcap (usually ts and te capabilities) such that
the pages are not switched.

>-- 
>
>--Phil Howard, KA9WGN-- | Individual CHOICE is fundamental to a free society
><phil@ux1.cso.uiuc.edu> | no matter what the particular issue is all about.


-- 
# The days of the computer priesthood are not over.
# May they never be.
# If it sounds selfish, consider how most companies stay in business.

tchrist@convex.COM (Tom Christiansen) (02/26/91)

From the keyboard of greywolf@unisoft.UUCP (The Grey Wolf):
:I would say that you have some sort of souped-up termcap that loves to
:use the memory-page capability of your terminal.  I would suggest that you
:use a slightly less sophisticated version of your termcap, or get your
:sysadmin to modify the termcap (usually ts and te capabilities) such that
:the pages are not switched.

You never need sysadmin help just for your own termcap.  $TERMCAP
set to a pathname works.

--tom
-- 
"UNIX was not designed to stop you from doing stupid things, because
 that would also stop you from doing clever things." -- Doug Gwyn

 Tom Christiansen                tchrist@convex.com      convex!tchrist

mouse@thunder.mcrcim.mcgill.edu (der Mouse) (02/28/91)

In article <3399@unisoft.UUCP>, greywolf@unisoft.UUCP (The Grey Wolf) writes:
> In article <1991Feb20.210427.26089@ux1.cso.uiuc.edu> phil@ux1.cso.uiuc.edu (Phil Howard KA9WGN) writes:
>> I want to make the "less" command NOT switch over to the alterate
>> screen.  This is so that when I press "q" to quit from less, it will
>> NOT switch back to the primary screen on me.

> I would say that you have some sort of souped-up termcap that loves
> to use the memory-page capability of your terminal.

It's also possible this person has been afflicted with xterm[%].  By
default, xterm does this.  I believe there is some resource that can be
set to disable it; the name "titeInhibit" comes to mind.  Check your
documentation.  (I suspect xterm is in commoner use than terminals that
are actually set up to use multiple pages of screen memory like this.)

[%] For those who don't know: xterm is a terminal emulator for The X
    Window System.

					der Mouse

			old: mcgill-vision!mouse
			new: mouse@larry.mcrcim.mcgill.edu

mouse@thunder.mcrcim.mcgill.edu (der Mouse) (02/28/91)

In article <1991Feb25.221941.7295@convex.com>, tchrist@convex.COM (Tom Christiansen) writes:
> You never need sysadmin help just for your own termcap.  $TERMCAP set
> to a pathname works.

Well, it uses a substitute termcap.  Unfortunately, it doesn't always
"work": SunOS 4.1, for example, has a vi that completely ignores
$TERMCAP.  (reset too, but that doesn't bother me - I never use it.)

(Really Sun, aintcha never heard of compatibility?  Major pain to be
suddenly unable to use vi.  Fortunately on the new SPARCs emacs starts
about as fast, so just scratch vi....)

					der Mouse

			old: mcgill-vision!mouse
			new: mouse@larry.mcrcim.mcgill.edu

gwyn@smoke.brl.mil (Doug Gwyn) (03/01/91)

In article <1991Feb28.142912.18391@thunder.mcrcim.mcgill.edu> mouse@thunder.mcrcim.mcgill.edu (der Mouse) writes:
>SunOS 4.1, for example, has a vi that completely ignores
>$TERMCAP.  (reset too, but that doesn't bother me - I never use it.)
>(Really Sun, aintcha never heard of compatibility?  Major pain to be
>suddenly unable to use vi.

That was unjustified -- if you had bothered to read the manual,
you might have discovered that SunOS "vi" these days uses terminfo,
not termcap.