Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!

Change the man page pager in 10.3 UNIX
I was using Mac OS X 10.2 (Jaguar) before I became reasonably comfortable using the Terminal. In that version of the OS, the default Terminal shell was tcsh, and the default pager (a program called more) would let me open a man page and go into it as far as I wanted (or even reach the end), and then use the Terminal window scroll bars or page up and page down keys to navigate back up through the text that had already been displayed in the window.

When I upgraded to Panther (10.3), I discovered that the default shell was bash instead of tcsh, and a different pager (called less) was being used by default, so that only the man page text appearing at the moment in the Terminal window was available for viewing. Once it disappeared from the window, I had to use keyboard shortcuts like Control-D and Conrol-U to navigate down for later man text and up arrow for previous man text. Generally, I prefer to use keyboard shortcuts rather than mouse maneuvers if I can remember the shortcuts. In this case, though, they interfered with shortcuts I had already programmed into QuicKeys. Also I wanted the page up and down keys to work like they do in other applications, and if I reached the end of the man page or hit Control-U too many times and went past the beginning, I found that the man text was gone, and I would have to reissue the man command.

Anyway, here's how I added an alias for the man command so that a different pager would be used, and I could once again keep all the man text available in the Terminal window where it was loaded.

Open a Terminal window and check its title bar to be sure that the shell being used is bash (if you haven't customized the window title, it should contain "bash"). If bash isn't the default shell, you can change that in the Terminal preferences by selecting "Execute this command (specify complete path):" and typing in "/bin/bash". If you changed your shell, you should continue in a new Terminal window.

Next, type pico .profile into the Terminal window and press return. If you haven't previously customized your bash login options, you'll see "New file" at the bottom of the window when you enter the Pico text editor. Now type alias man="man -P more", and press Control-O to submit the changes. Type Y if prompted to confirm, followed by a carriage return to accept the file name. Then type Control-X to exit the Pico program.

Now open a new Terminal window to see the results. You might want to type in a man command that will result in displaying a manual entry with several pages, such as man ls or man bash.

[robg adds: There are some key differences between less and more, and people seem to prefer one or the other. A previous hint explains how to stop the less pager from clearing the screen, which helps a lot. Also, you can use the up and down arrows to scroll through documents that less is paging. Finally, you may already have a .bash_profile file in your home directory; if you do, add the above command to it instead of creating a new .profile file.]
    •    
  • Currently 1.00 / 5
  • 1
  • 2
  • 3
  • 4
  • 5
  (2 votes cast)
 
[10,010 views]  

Change the man page pager in 10.3 | 15 comments | Create New Account
Click here to return to the 'Change the man page pager in 10.3' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Change the man page pager in 10.3
Authored by: ashill on Sep 15, '04 11:20:27AM

You can set this more cleanly using the PAGER environment variable, which also affects most other programs that use a pager.

For example, to use less as the pager in tcsh, put setenv PAGER less in your ~/.cshrc file (or some other appropriate place). If you so desire, you can also use arguments such as setenv PAGER less -c.

In bash, it would be PAGER=less; export PAGER.

You can then still override your default pager when you run man with the -P option.

[ Reply to This | # ]

Change the man page pager in 10.3
Authored by: ua on Sep 15, '04 12:53:20PM
...or even
export PAGER=less


[ Reply to This | # ]
Use ~/.MacOSX/environment.plist
Authored by: n8gray on Sep 15, '04 08:39:48PM

If you want to set an environment variable that will be valid in *all* shells and *all* programs the best place for it is ~/.MacOSX/environment.plist. The downside is you'll need to log out and log back in for changes to take effect.



[ Reply to This | # ]
Change the man page pager in 10.3
Authored by: kirkmc on Sep 15, '04 11:50:15AM

There's just one problem with this hint.... In Panther, more _is_ less.

Type man more; you get the less man page. Apple replaced more with less, even though more is still listed in /usr/bin. The more executable is merely less with a different name.



[ Reply to This | # ]
Change the man page pager in 10.3
Authored by: durin on Sep 15, '04 12:40:19PM

True, but less imitates more when executed as more.

---
Go not to the elves for council, they will say both no and yes



[ Reply to This | # ]
Change the man page pager in 10.3
Authored by: gvaughn on Sep 15, '04 12:10:12PM
A while back I ran across AquaLess and I set that as my PAGER. It's great for man pages because it opens a separate scrollable window. I often refer back and forth to the man page and command prompt as I build up a complicated set of command line switches.

[ Reply to This | # ]
Change the man page pager in 10.3
Authored by: ngb on Sep 15, '04 12:35:47PM

I am a big fan of ManOpen, a GUI app for reading man pages that can be launched from the command line. Man pages can be read, scrolled through and searched, leaving the terminal free to try out the command.

http://www.clindberg.org/projects/ManOpen.html



[ Reply to This | # ]
Change the man page pager in 10.3
Authored by: TheGS on Sep 15, '04 01:02:56PM

This is slightly off-topic, but the basic keyboard shortcuts for less aren't difficult to remember. Another poster reminded that in Panther, more is symlinked to less, so they can apply even if you changed the $PAGER to point to more.

Aside from the obvious space bar to scroll the man page down by one screen, less also supports the up and down arrow keys and 'j' and 'k' keys familiar from vi (among others) — you don't have to take you fingers off the home row!



[ Reply to This | # ]
less -X
Authored by: enigmamf on Sep 15, '04 01:58:28PM

Wow, I am bewildered -- less is so much better I can't imagine anyone wanting to use more anymore. Need to do a search? Less will highlight every result, making scanning for what you really want easier. Need to search above where you already are? Use a question mark instead of a forward slash to search backwards -- no need to bring yourself to the top of the document.

To get around the disappearing less text, I've set up the following alias:

For you firm souls who think for yourself and stick to TCSH even in the face of Apple's Bashification:
alias less less -X
or for you bash types
alias less="less -X"



[ Reply to This | # ]
less -X
Authored by: mike3k on Sep 15, '04 02:15:37PM

You can also set the environment variable LESS to force -X.

in bash, add the following to your .bashrc or .bash_profile:

export LESS='-X'



[ Reply to This | # ]
Change the man page pager in 10.3
Authored by: soulrider2k on Sep 15, '04 07:27:06PM

Or, instead of all this malarkey, simply change your terminal prefs (under the Terminal menu) to use vt110 instead of xterm-color, rxvt, dtterm etc.

---
soulrider2k



[ Reply to This | # ]
I was wondering!
Authored by: jbc on Sep 15, '04 09:52:04PM

This is the first thing I tried when I found Panther's Terminal wouldn't let me use scrollback properly anymore. Setting the Terminal to VT110 pretty much restored the behavior of the terminal to what I was accustomed. Never knew it had anything to do with the pager!



[ Reply to This | # ]
Terminal clearing
Authored by: Ptitboul on Sep 16, '04 08:31:19AM

This is not a "terminal clearing" problem, but an "alternate screen" problem.
xterm-like terminals have two display area : the main area and the "alternate" area, which is dedicated for programs that temporarily need to display something without erasing the main display screen. This is a FAQ. Cf. http://dickey.his.com/xterm/xterm.faq.html#xterm_tite
http://lists.gnu.org/archive/html/screen-users/2004-07/msg00044.html
http://pirlwww.lpl.arizona.edu/user_notes/user_notes.cgi?id=97

Changing the terminal type to something else than xterm-color, that does not have an alternate screen, is not a good solution because it changes many other properties of the terminal.

Changing the pager is supposed to be done with the environment variable PAGER, automatically adding options to less (e.g. -X) is also supposed to be done with an environment variable : LESS, and not with an alias.



[ Reply to This | # ]
Dissapearing man page text is a bonus
Authored by: makip on Sep 20, '04 09:37:39AM

I always considered the dissapearing man page text as a feature. It allows me to see my previous command line history prior to the man invocation - which is the behavior I want most of the time.

If I wanted to keep the man page text available as a reference, I have always been in the habit of hitting ctrl-n for a new term window, and then typing man command

This is more flexible as a reference, it allows quick key presses to navigate the man page, and you can have your other terminal along side to construct the command you're typing, with its man page there as a reference.

And as a previous poster has mentioned, less has improved searching abilities to more.



[ Reply to This | # ]
Dissapearing man page text is a bonus
Authored by: osxpounder on Sep 20, '04 11:53:59AM

I'm puzzled a bit, because for me, when I type "man bash" in iTerm, I get the ability to use the "page up" and "page down" keys on my keyboard already .... it just works.

---
--
osxpounder



[ Reply to This | # ]