5

On a Debian system, one can type pager in order to use whatever pager program happens to be default/available. By default, less is used, and if not available, the lesser more gets to do the job. Is such a thing available in other Unix and Linux systems?

tshepang
  • 64,472
  • 86
  • 223
  • 290

3 Answers3

7

The unix tradition is for applications that want to call a pager to call $PAGER, i.e. use the contents of the environment variable PAGER as a command name. (Whether shell metacharacters are expanded in $PAGER is not consistent between applications.) The unix tradition further uses more if the PAGER variable is not set. There is a similar tradition for text editors: use $EDITOR (or, for historical reasons, $VISUAL), falling back to vi.

Having a command named pager is specific to Debian (and derivatives, including Ubuntu). /usr/bin/pager is in fact a symbolic link to /etc/alternatives/pager, which points to the the “best” available pager (the Debian maintainers decide which is best, and the system administrator can override their choice), using the alternatives framework.

Debian also provides /usr/bin/sensible-pager. This script runs $PAGER if the variable is set, and falls back to pager otherwise. Its purpose is to be used in programs where a single pager path has to be hard-coded. This behavior is documented in the Debian policy manual.

Gilles 'SO- stop being evil'
  • 807,993
  • 194
  • 1,674
  • 2,175
  • 1
    Just as an addendum, while not included by default, a `pager` generic could be used by the alternative system that is found in Red Hat derivatives such as Fedora. Also, if one really wanted to, I'll bet one could implement such a system on other Unixes since I've seen alternative frameworks implemented in perl. – Steven D Jan 04 '11 at 20:42
  • @Steven: It's [not surprising](http://lists.debian.org/debian-curiosa/2002/06/msg00000.html) that Red Hat's alternatives look like Debian's. And the framework *is* implemented as a Perl script (`/usr/bin/update-alternatives`) — [or was](http://raphaelhertzog.com/2010/05/27/rewriting-update-alternatives-in-c/). – Gilles 'SO- stop being evil' Jan 04 '11 at 21:13
  • [POSIX specifies that `man` shall interpret `$PAGER` as an string passed to `sh -c`](https://pubs.opengroup.org/onlinepubs/9699919799/utilities/man.html). So at least `man` recognises metachars in `$PAGER`. – Tom Hale Aug 29 '20 at 10:00
5
$ update-alternatives --list pager
/bin/less
/bin/more
/usr/bin/pg
/usr/bin/w3m

YMMV depending on what you have installed, but this is Debian-specific (well, and derivatives too).

Customarily one uses $PAGER with a fallback to more.

ephemient
  • 15,640
  • 5
  • 49
  • 39
1

All Linux-Distributions I have used so far (Gentoo, Debian, Slackware, Fedora, OpenSuse) had an Environment-Variable called PAGER which set the pager (default, as said, less). It's set in your shell environment.
I think the command man uses this variable..

fakemustache
  • 171
  • 6