8

I'd like to use the scroll wheel (xterm mouse escape codes) to scroll through man pages, like I can in emacs with xterm-mouse-mode. less doesn't seem to have support for that and short of recompiling it I can't find a way to add it.

Is there a different pager I could use that supports the scroll wheel (or a way I could get less to do it)? I'd rather not give up bold and underline if possible.

My emulator is iTerm2 on Mac OS X Yosemite, if that helps.

18
  • 1
    I am a little confused by your question, because usually terminals already have a scrolling support in place to look at past output, so how would your system interact with the terminal exactly? Would it override the existing one for the duration of the pager runtime?
    – didierc
    Commented Feb 13, 2015 at 1:33
  • @didierc: I'm not sure about the specifics, but basically it would use whatever escape code it is to tell the terminal that the alternate screen buffer supports xterm mouse codes and to report them to the program. I think both emacs and vim support them. (Quick edit: it's called alternateScroll.)
    – 0942v8653
    Commented Feb 13, 2015 at 2:21
  • 3
    This is definitely possible. less and man scroll for me with the scroll wheel (in terminator). Unfortunately, I can't remember what I changed, if anything. This might be useful, but I can't understand where to set options.
    – Sparhawk
    Commented Feb 13, 2015 at 2:25
  • @Sparhawk: What's your setup? Distro? coreutils? My less version is 418. I compiled less 458 and that didn't help, so it might be something else.
    – 0942v8653
    Commented Feb 13, 2015 at 2:28
  • 1
    @mikeserv FWIW I use bash. Also, as above, it also works over an ssh session (which is also bash), with no X forwarding.
    – Sparhawk
    Commented Feb 13, 2015 at 4:24

6 Answers 6

4

I set my terminal emulator to send arrow keys for the scroll wheel when in alternate screen mode.

In iTerm2, that's under Preferences > Advanced and search for "scroll".

It doesn't interfere with xterm escape codes when something supports it, but when it does not (like in less), it sends arrow keys instead. Still not a complete solution, but better than nothing. (I think that's what Sparhawk's terminator was doing in the comment section above)

4
  • I don't know how it works, but my scroll wheel is definitely not just sending arrow keys. For example, in vim, scroll wheel scrolls the page, and arrows move cursor position.
    – Sparhawk
    Commented Feb 14, 2015 at 10:58
  • That's because vim supports the scroll wheel. For me emacs is the same way—even when I turned that on, it worked the way it always has.
    – 0942v8653
    Commented Feb 14, 2015 at 13:02
  • Ah okay. I just re-read your answer. That makes sense.
    – Sparhawk
    Commented Feb 14, 2015 at 13:13
  • Where did you find Advanced in the Preferences of iTerm2?!
    – astorije
    Commented Jul 6, 2015 at 9:31
4

w3m can be a decent pager (though I do prefer less). It supports the mouse (you may need to enable this in the configuration), including scrolling.

Vim is a text editor but can be used as a pager: set PAGER='vim -R'. You can enable mouse support with set mouse=a in your ~/.vimrc. The wheel works at least in xterm, I can't vouch for OSX's terminal emulator.

1

It seems this is possible using WoMan in Emacs.

According to http://www.emacswiki.org/emacs/WoMan “woman” stands for “w/o man”, ie “without man” and allows you to view man pages without having the “man” program installed.

In Emacs enter:

M-x woman

Where M-x is the Alt key followed by the letter x.

You will then be prompted to specify the man page you wish to view.

1
  • +1, this is helpful, but I'm really looking for an alternative pager. If there's nothing else I can use that, but I'd really rather stick to stock man.
    – 0942v8653
    Commented Feb 13, 2015 at 2:40
1

Now less itself supports mouse wheel, with --mouse and --wheel-lines. So you can use

man --pager='less --mouse --wheel-lines=<N>' <page>

Plus, you can

export PAGER='less --mouse --wheel-lines=<N>'

so other programs using this variable, like git log, can also benefit.

1
  • I am afraid this solution is linux-only oriented. When, from some OP's comment on another answer, I understand that OP's (running mac) version of man does not support the --pager option. (things could have evolved in 9 years, I don't know, I suggest you recheck.
    – MC68020
    Commented Apr 1 at 9:23
0

you can use cat

man --pager=cat <page>

or you can pipe the man page into cat

man <page> | cat
2
  • 1
    My version of man (on a Mac) doesn't work with --pager, but more importantly cat starts at the end of the document and there's no easy way to get up to the top.
    – 0942v8653
    Commented Feb 13, 2015 at 1:01
  • 1
    I want something that supports xterm mouse escape codes, and as I said, starts at the top.
    – 0942v8653
    Commented Feb 13, 2015 at 1:02
0

PAGER='vim -R' may result in some errors.
You can try this addon vim-superman.
if you met this error when executing vman man, you can try making your font smaller to solve it.

    troff: <standard input>:587: warning [p 7, 8.0i]: cannot adjust line

You may find it helpful to solve the tab completion problem

     bash: completion: function `_man' not found
0

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .