Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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.

share|improve this question
    
Like @garyjohn's answer I had thought I had got this functionality with less but on my work computer, it's not working like I want it to –  funk-shun May 17 '11 at 22:02

3 Answers 3

up vote 3 down vote accepted

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.

share|improve this answer
    
i think that's the problem! but how do I check what's in the LESS environment variable that's interfering with this behavior? –  funk-shun May 17 '11 at 22:01
1  
Executing echo $LESS will show you what's in the variable, then man 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 is X, 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." –  garyjohn May 17 '11 at 22:49
    
when I echo $LESS I just get a blank line :( –  funk-shun May 17 '11 at 23:14
    
It may be your terminal rather than less that's controlling this, although that doesn't explain vim's ability to control it. With an xterm, 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 for less to work as you'd like it to. This may also be controlled by the titeInhibit X resource. I don't know how it is controlled in any other terminal type, but if you're not using an xterm, maybe that will give you some terms to look for. –  garyjohn May 18 '11 at 0:16
    
i'm using Mac OS X Terminal :( –  funk-shun May 19 '11 at 17:40

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

share|improve this answer

There is a command generally available called view which basically just runs vi/vim in read-only mode.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.