开发者

Mac Terminal show end of buffer

When I call commands like man, it puts everything into a buffer and only shows one page at a time. I can navigate with my arrow keys or my space bar but I want it to show everything at once without me having to scroll through it. What do I need to do in order to change it? I'm pretty sure it's some key bind but I can't figure it out.

I would prefer it if it would simply just automatically scroll to the end. If there's some command I can enter to make it automatically do this, please let me know. If I have to use a key bind instead to make it scroll down to the end of the buffer, or send开发者_JS百科 everything to the shell, then let me know.

If I'm doing a key bind, I'd prefer it to be something like shift/command + down to scroll all the way down. And then I'd probably map a similar one to go back up.

Thanks.


When you use man, it's piping your result through a pager. If you haven't configured it, on the Mac this is /usr/bin/less -is.

One way to bypass the pager is by setting it to ul. For example:

% man -P ul ls 
LS(1)                     BSD General Commands Manual                    LS(1)
[...]

ul is a filter that ensures boldface and underlining are preserved. They're encoded in a rather archaic way by X^HX and X^H_ respectively, which modern terminals don't support; pagers ordinarily translate these into terminal escape sequences by themselves.

With man, there are a couple of other options:

  1. In OS X 10.5 and later, you can use the Help menu to get man pages. Just press / and type the name of the page you want, then select it from the menu (although I think this uses a fixed path unfortunately). This just runs man -P ul for you in a new Terminal window.
  2. Another is to render into PostScript, which OS X can convert into a PDF, nicely formatted for printing if you want. I've been using this zsh function for years:

     gman() {
       PDF=/tmp/man.$$.pdf
       print 'Converting to PDF...'
       man -t $@ | /usr/bin/pstopdf -i -o $PDF
       print 'Opening...'
       open $PDF
       { sleep 5; rm -f $PDF } &!
     }
    


Changing the pager to cat instead of the default (/usr/bin/less -is on my machine) should do what you want. From the man(1) man page:

-P pager

Specify which pager to use. This option overrides the MANPAGER environment variable, which in turn overrides the PAGER variable. By default, man uses /usr/bin/less -is. '

So you can either do man -P cat whatever, or you can set MANPAGER and/or PAGER in your environment to cat and get the same behaviour.


The less pager which is usually the default on most systems already has key bindings to go directly to the end and start of its input:

  • g will go to the start of the input
  • G (which would actually be something along the lines of Shift+g, unless you type with Caps Lock on) will go to the end of the input
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜