Mac 终端显示缓冲区末尾

发布于 2024-10-30 18:40:49 字数 314 浏览 1 评论 0原文

当我调用像 man 这样的命令时,它会将所有内容放入缓冲区中,并且一次只显示一页。我可以使用箭头键或空格键进行导航,但我希望它能够立即显示所有内容,而无需滚动浏览。我需要做什么才能改变它?我很确定这是一些按键绑定,但我无法弄清楚。

如果它只是自动滚动到末尾,我会更喜欢它。如果我可以输入一些命令使其自动执行此操作,请告诉我。如果我必须使用按键绑定来使其向下滚动到缓冲区的末尾,或者将所有内容发送到 shell,请告诉我。

如果我正在进行按键绑定,我希望它是像 Shift/Command + Down 那样一直向下滚动。然后我可能会绘制一个类似的地图来返回。

谢谢。

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 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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

最美的太阳 2024-11-06 18:40:49

当您使用 man 时,它会通过寻呼机传送您的结果。如果您尚未配置它,则在 Mac 上这是 /usr/bin/less -is

绕过寻呼机的一种方法是将其设置为 ul。例如:

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

ul 是一个过滤器,可确保保留粗体和下划线。它们分别通过 X^HXX^H_ 以相当古老的方式进行编码,现代终端不支持这种方式;寻呼机通常自行将它们翻译成终端转义序列。

对于 man,还有其他几个选项:

  1. 在 OS X 10.5 及更高版本中,您可以使用
    帮助菜单获取手册页。
    只需按
    <代码>/
    并输入您要访问的页面的名称
    想要,然后从菜单中选择它(尽管我认为这使用了
    不幸的是固定路径)。这
    只需在新的终端窗口中运行 man -P ul 即可。
  2. 另一个是渲染成
    PostScript,OS X 可以转换
    转换为 PDF,格式精美
    如果需要的话可以打印。我去过
    使用这个 zsh 函数多年:

    <前><代码> gman() {
    PDF=/tmp/man.$$.pdf
    打印“正在转换为 PDF...”
    人 -t $@ | /usr/bin/pstopdf -i -o $PDF
    打印“打开...”
    打开$PDF
    { 睡觉 5; rm -f $PDF } &!
    }

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 } &!
     }
    
笑饮青盏花 2024-11-06 18:40:49

将寻呼机更改为 cat 而不是默认值(在我的机器上为 /usr/bin/less -is)应该可以满足您的要求。从 man(1) 手册页

-P 寻呼机

指定要使用的寻呼机。此选项会覆盖 MANPAGER 环境变量,而环境变量又会覆盖 PAGER 变量。默认情况下,man 使用/usr/bin/less -is
'

因此,您可以执行 man -P catwhatever,或者您可以将环境中的 MANPAGER 和/或 PAGER 设置为 cat 并获得相同的行为。

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.

拒绝两难 2024-11-06 18:40:49

less 分页器通常是大多数系统上的默认设置,它已经具有可直接转到输入的结尾和开头的键绑定:

  • g 将转到输入的开头
  • G(实际上类似于 Shift+g,除非您在打开 Caps Lock 的情况下键入)将转到输入的末尾

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
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文