5

Having many short mail messages in my inbox, it's quite annoying that even short messages are sent though a pager (less), requiring to press 'q' before I can view the next message (for example).

I read the manual page about pager, but none of these did work:

PAGER= mailx set pager= unset pager unset PAGER 

How can I disable the pager? I'm using mailx 12.5 of SLES 15 SP3.

1 Answer 1

10

There are two major problems that prevent an easy solution for the problem:

  1. As indicated in the mailx man page (SLES ships Nail’s mailx), “Variables in the environment passed to mailx cannot be unset.”

  2. PAGER (as set from within mailx) cannot have parameters, so something like set PAGER="LESS=-F less" or set PAGER="sh -c LESS=-F less" do not work. To make things worse, there is no output if you try something like set PAGER="less -F".

So the alternatives are:

  1. mailx can be configured to skip the pager if a message fits in a single screen by setting the crt option (that requires the number of lines of the terminal normally): add

    set crt 

    to your .mailrc. Without a value, the version of mailx available in SLES uses the current screen height; POSIX doesn’t specify the behaviour when crt is set without a value, so a POSIX-compliant approach is either to set it to 99999 (to always skip the pager) or a typical value for your work environment (to only use the pager when necessary).

  2. The pager can also be replaced with a non-paging display tool, e.g. cat when starting mailx from a Bourne-shell-like interpreter:

    PAGER=cat mailx 
  3. If your pager is less, you can ask it to quit without prompting if it has less than a screen’s worth of text to display, using its -F option (again using sh syntax):

    LESS=F mailx 

    If you want to combine -F with other options set in your LESS variable, use

    LESS="$LESS -F" mailx 

    This can be enabled in general by exporting LESS=F (and any other less option you want to enable by default) in your shell startup script.

    In versions of less older than 530, you may need to combine -F and -X (LESS=FX).

2
  • OK that's actually a solution wile I'm waiting for better answers. Can I make such a setting permanent (i.e. automatic) inside less? Commented Mar 28, 2022 at 6:37
  • set crt is a good idea. If it could do the magic that resize can do (i.e. find out the height of the terminal) all would be just "automatic". Commented Mar 28, 2022 at 9:32

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.