LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 02-03-2014, 12:33 PM   #1
Clovis_Sangrail
LQ Newbie
 
Registered: Mar 2012
Posts: 13

Rep: Reputation: Disabled
Smile How can I preserve screen on exit from 'man' or 'less'?


Hello,
Alright linuxquestions.org website, you've noted nearly 1000 times that I've never posted a question, and that I'm missing out on all the wonderful benefits thereto appertaining. So here goes:

On SunOS, Solaris, AIX, (most any *nix save for Linux pretty much), when I <ctrl/c> out of a 'man' page or quit out of 'less', whatever I was looking at STAYS DISPLAYED ON THE TERMINAL WINDOW and I get a command prompt at the bottom of the terminal. This is great, because what is displaying on the screen is typically the option/switch/syntax/ whatever answer I've been looking for, and have now found, and I am now perfectly and conveniently positioned to use that answer in whatever program/command/utility that I was trying to run.

Except in Linux.

In Linux my long-sought-and-finally-found new knowledge and intelligence VANISHES as soon as I exit the 'man' or 'less' command. I had it, right there!! I was all set to USE IT at the command prompt!! But now I can't, BECAUSE IT IS GONE!!!

Why is this?? What is the advantage to that?? And please, unless you are going to buy me more monitor real estate DON'T TELL ME TO OPEN UP ANOTHER TERMINAL WINDOW! I KNOW I CAN OPEN UP ANOTHER TERMINAL WINDOW. I CAN BUY ANOTHER COMPUTER AND SET IT UP NEXT TO THE ONE I AM USING, TOO, BUT BOTH IDEAS SEEM STUPID TO ME.

Perhaps it's because it annoys me as much as it obviously does, or perhaps it's because whenever I encounter this PITA I am in the midst of dealing with some other PITA that has driven me to consult man pages or other documentation in the 1st place, but I have a difficult time calmly seeking solutions to this problem. I don't even know wherein it lies, really. Is this behavior determined by stty settings or termio characteristics? Is it actually built into the 'man', 'less', and other executables, or some library that they call? Or is it determined someplace else?

Has anyone already doen something about this annoyance? Has anyone fixed 'man' and 'less', or resolved it in some other way?

Anyhow, I asked my question. So, ummm, what about all these great bennies??
 
Old 02-03-2014, 12:37 PM   #2
Habitual
LQ Veteran
 
Registered: Jan 2011
Location: Abingdon, VA
Distribution: Catalina
Posts: 9,374
Blog Entries: 37

Rep: Reputation: Disabled
Quote:
Originally Posted by Clovis_Sangrail View Post
Has anyone fixed 'man' and 'less', or resolved it in some other way?
I've used
Code:
export LESS='FiX'
in my .bashrc for YEARS
 
3 members found this post helpful.
Old 02-03-2014, 01:24 PM   #3
Clovis_Sangrail
LQ Newbie
 
Registered: Mar 2012
Posts: 13

Original Poster
Rep: Reputation: Disabled
Really?? Thanks!! I'm at work now, but I'll check it out tonight!
 
Old 02-03-2014, 01:47 PM   #4
Habitual
LQ Veteran
 
Registered: Jan 2011
Location: Abingdon, VA
Distribution: Catalina
Posts: 9,374
Blog Entries: 37

Rep: Reputation: Disabled
Don't forget to source your ~/.bashrc after editing
Code:
source ~/.bashrc

Last edited by Habitual; 06-26-2015 at 05:47 PM.
 
Old 02-04-2014, 12:00 PM   #5
Clovis_Sangrail
LQ Newbie
 
Registered: Mar 2012
Posts: 13

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by Habitual View Post
Don't forget to source your ~/.bashrc after editing
Code:
source ~/.bashrc
I'll add this to .bashrc eventually, but for now I enjoy typing it at the command line! This is as useful an addition to my understanding of 'less' (and therefore to the man manuals in Linux, I guess) as is typing "-N" to toggle the line number display.

I never knew there was an environment variable for less. It looks like it's the 'X' part that fixes the problem, by suppressing certain terminal commands on exit. I suppose further research into that, and why it differs for different Unixes, is now someplace in my to-do pile.

Again, thank you!
 
Old 02-04-2014, 12:17 PM   #6
TobiSGD
Moderator
 
Registered: Dec 2009
Location: Germany
Distribution: Whatever fits the task best
Posts: 17,148
Blog Entries: 2

Rep: Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886
Quote:
Originally Posted by Clovis_Sangrail View Post
I'll add this to .bashrc eventually, but for now I enjoy typing it at the command line! This is as useful an addition to my understanding of 'less' (and therefore to the man manuals in Linux, I guess) as is typing "-N" to toggle the line number display.

I never knew there was an environment variable for less. It looks like it's the 'X' part that fixes the problem, by suppressing certain terminal commands on exit. I suppose further research into that, and why it differs for different Unixes, is now someplace in my to-do pile.

Again, thank you!
The fun part is, while ranting about the behavior of man and less you seem to not have checked the man-page of less, where the environment variable is extensively described, with all options. It is indeed the X part that causes the wanted behavior:
Code:
-X or --no-init
    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.
Tip for the future: Writing in all caps and using oversized fonts counts as yelling and is considered to be rude on most forums. This may deter members of LQ from actually helping you.
 
Old 02-04-2014, 12:57 PM   #7
mdooligan
Member
 
Registered: Feb 2009
Location: Vancouver BC
Distribution: Mandrake10/ArchHackery/Gentoo
Posts: 179

Rep: Reputation: 22
I use less -XCr~.

I don't like that -F thing. On short file it flashes screen and does nothing.
 
2 members found this post helpful.
Old 02-05-2014, 09:12 AM   #8
Habitual
LQ Veteran
 
Registered: Jan 2011
Location: Abingdon, VA
Distribution: Catalina
Posts: 9,374
Blog Entries: 37

Rep: Reputation: Disabled
Quote:
Originally Posted by Clovis_Sangrail View Post
I'll add this to .bashrc eventually, but for now I enjoy typing it at the command line! This is as useful an addition to my understanding of 'less' (and therefore to the man manuals in Linux, I guess) as is typing "-N" to toggle the line number display.

I never knew there was an environment variable for less. It looks like it's the 'X' part that fixes the problem, by suppressing certain terminal commands on exit. I suppose further research into that, and why it differs for different Unixes, is now someplace in my to-do pile.

Again, thank you!
You're welcome.

NOTE: I use a reload alias in my .bashrc explicitly for this purpose
Code:
alias reload='clear && source ~/.bashrc'
"clear &&" is optional, but I prefer to have a clean screen.

Enjoy the Goodness!

Last edited by Habitual; 02-05-2014 at 09:14 AM.
 
Old 02-07-2014, 03:04 PM   #9
Clovis_Sangrail
LQ Newbie
 
Registered: Mar 2012
Posts: 13

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by TobiSGD View Post
The fun part is, while ranting about the behavior of man and less you seem to not have checked the man-page of less....
It's only recently that I realized it was necessary to check out 'less' at all. In other Unixes I've used 'less' is not the pager employed by the 'man' facility.
 
Old 02-07-2014, 03:08 PM   #10
Clovis_Sangrail
LQ Newbie
 
Registered: Mar 2012
Posts: 13

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by mdooligan View Post
I use less -XCr~.

I don't like that -F thing. On short file it flashes screen and does nothing.
This is another one that I have to try out when I have access to a Linux box (and power to run it..). Thanks!
 
Old 02-07-2014, 03:50 PM   #11
jlliagre
Moderator
 
Registered: Feb 2004
Location: Outside Paris
Distribution: Solaris 11.4, Oracle Linux, Mint, Debian/WSL
Posts: 9,789

Rep: Reputation: 492Reputation: 492Reputation: 492Reputation: 492Reputation: 492
Quote:
Originally Posted by Clovis_Sangrail View Post
On SunOS, Solaris, AIX, (most any *nix save for Linux pretty much), when I <ctrl/c> out of a 'man' page or quit out of 'less', whatever I was looking at STAYS DISPLAYED ON THE TERMINAL WINDOW and I get a command prompt at the bottom of the terminal. This is great, because what is displaying on the screen is typically the option/switch/syntax/ whatever answer I've been looking for, and have now found, and I am now perfectly and conveniently positioned to use that answer in whatever program/command/utility that I was trying to run.

Except in Linux.
Not sure about the other OS mentioned but ironically, the Solaris behavior you describe was not a feature but a bug that was fixed in the last release (Solaris 11).

Instead of using hard to remember extra options or settings, a more radical way is simply to remove the alternate screen abomination (rmcup/smcup) from the terminfo entry your terminal emulator uses.

I'm doing that to every Unix/Linux machine I own/administrate.
 
Old 02-11-2014, 12:57 PM   #12
Clovis_Sangrail
LQ Newbie
 
Registered: Mar 2012
Posts: 13

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by jlliagre View Post
... a more radical way is simply to remove the alternate screen abomination (rmcup/smcup) from the terminfo entry ....
When I encounter the portions of *nix that predate the Internet, I begin to feel less like a SysAdmin and more like an Archeologist. Terminfo, ttydb, tip, cu, ... these are all things from an earlier time and I know much less of them than the more modern parts of Unix. Do you have an overall sense of how much xterm, dtterm, and other GUI/Internet emulations of tools from the teletype/serial-terminal era interface with and make use of facilities like terminfo and follow their conventions, and how much they ignore the old tools, possibly 're-inventing the wheel' so to speak?
 
Old 02-12-2014, 07:20 AM   #13
mdooligan
Member
 
Registered: Feb 2009
Location: Vancouver BC
Distribution: Mandrake10/ArchHackery/Gentoo
Posts: 179

Rep: Reputation: 22
Quote:
Originally Posted by Clovis_Sangrail View Post
When I encounter the portions of *nix that predate the Internet, I begin to feel less like a SysAdmin and more like an Archeologist. Terminfo, ttydb, tip, cu, ... these are all things from an earlier time and I know much less of them than the more modern parts of Unix.
Well put, friend. Termcap, too. I still run into things that use that.

VT100 emulation? All the variations on which ANSI escape sequences can make the cursor go to the beginnning or end of the line? Whether you use xterm, rxvt, gnome-terminal, etc, and which ones do they obey, and which ones did they invent to support transparency and right-to-left fonts? Line drawing characters and alternate character sets. Console codes. The list goes on...
 
Old 02-12-2014, 07:41 AM   #14
mdooligan
Member
 
Registered: Feb 2009
Location: Vancouver BC
Distribution: Mandrake10/ArchHackery/Gentoo
Posts: 179

Rep: Reputation: 22
Quote:
Originally Posted by jlliagre View Post
Instead of using hard to remember extra options or settings, a more radical way is simply to remove the alternate screen abomination (rmcup/smcup) from the terminfo entry your terminal emulator uses.

I'm doing that to every Unix/Linux machine I own/administrate.
See, that makes you clever. You even *knew* the appropriate abominations to delete Deep Voodoo.
 
Old 02-12-2014, 07:50 AM   #15
jlliagre
Moderator
 
Registered: Feb 2004
Location: Outside Paris
Distribution: Solaris 11.4, Oracle Linux, Mint, Debian/WSL
Posts: 9,789

Rep: Reputation: 492Reputation: 492Reputation: 492Reputation: 492Reputation: 492
There are not that much applications using termcap on Linux. Some of the ones that needs to format their output are based on ncurses. This include elvis, htop, nano, pico, watch. Most of them are however directly using terminfo like pico, pstree, screen, top, vim ...

Back to the topic, another similar abomination that I always remove from the accounts I use is the default .bash_logout script that clears the screen at logout.
 
1 members found this post helpful.
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
To properly exit man pages grautu Linux - Newbie 7 08-18-2012 06:07 AM
how to exit/quit man? Mountain Linux - Newbie 4 11-07-2007 05:49 PM
exit a man page? gnuoob Linux - Newbie 2 08-27-2005 01:39 PM
man pages: how to exit? KlaymenDK Linux - Newbie 2 06-25-2004 08:03 AM
Exit man (elegantly) verstapp Linux - Newbie 2 03-01-2004 07:29 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 08:48 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration