Sorry for the awkward phrasing of the title but I was wondering if there was a text viewer (like more or less) that takes you away from the command prompt when you're viewing a doc and then when you quit the viewer, you're right back at the last command you typed. Like how vim functions. So I guess vim would work but I was wondering if there was another text viewer that's simpler.
3 Answers
I'm not sure, but I think what you're referring to is the use by some programs such as Vim of the terminal's alternate screen. I'm using less
version 429 in a GNOME Terminal 2.26.3.1 under KDE on a Fedora 11 system. When I clear the LESS
environment variable before running less
, e.g.,
$ ls | LESS= less
then quit less
, the screen is restored to the state it was in before running less
. So, check the value of LESS
and see if it contains something that's interfering with that behavior.
-
i think that's the problem! but how do I check what's in the LESS environment variable that's interfering with this behavior? Commented May 17, 2011 at 22:01
-
1Executing
echo $LESS
will show you what's in the variable, thenman less
will show you what each of those letters means.less --help
will give you more terse explanations. I think the option/letter controlling this behavior isX
, which "Disables sending the termcap initialization and deinitialization strings to the terminal. This is sometimes desirable if the deinitialization string does something unnecessary, like clearing the screen."– garyjohnCommented May 17, 2011 at 22:49 -
-
It may be your terminal rather than
less
that's controlling this, although that doesn't explainvim
's ability to control it. With anxterm
, you can hold the Ctrl key while pressing the middle mouse button and see a menu that includes "Enable Alternate Screen Switching". That should be checked forless
to work as you'd like it to. This may also be controlled by thetiteInhibit
X resource. I don't know how it is controlled in any other terminal type, but if you're not using anxterm
, maybe that will give you some terms to look for.– garyjohnCommented May 18, 2011 at 0:16 -
Try nano and pico.
IIRC, they don't mess with the contents of your session. They are also way simpler. If you don't need to edit and only want to output the files, then you just need
'cat filename'
and it won't even leave your shell to create any fullscreen viewer environment such as your experience with vi
There is a command generally available called view
which basically just runs vi/vim in read-only mode.