zsh`history n`显示前n个条目,而不是后n个条目

Liu*_*Sha 1 zsh

我读了文档history,上面写着:

  history [n]
  history -c
  history -d offset
  history -anrw [filename]
  history -p arg [arg ...]
  history -s arg [arg ...]
          With no options, display the command history list with line
          numbers.  Lines listed with a *  have  been  modified.   An
          argument  of  n  lists only the last n lines.  
Run Code Online (Sandbox Code Playgroud)

但是在我的zsh中,它始终显示前n行。我需要使用history | tail -n来显示最后几行。

  1. 是否有任何选项设置错误?如何纠正?
  2. 此外,如何在没有行号和时间戳的情况下打印历史记录,以便将部分历史记录转换为脚本

Ry-*_*Ry- 5

historyzshbuiltins(1)中zsh的文档为:

历史

与相同fc -l

在哪里fc -l

fc -l [-LI] [-nrdfEiD] [-t timefmt] [-m match] [old = new ...] [first [last]]

如果first未指定,则将其设置为-1(最近的事件),或者如果设置了-l标志,则设置为-16 。如果last未指定,则将其设置为first,如果指定了-l标志,则将其设置为-1 。然而,如果当前事件已添加的条目与历史print -sfc -R,则默认last-l包括由于本次活动开始所有新的历史记录条目。

-l给定标志,则所得的事件都被列在标准输出。

因此运行:

history -<n>
Run Code Online (Sandbox Code Playgroud)

用连字符号减,如中所示history -16,以查看zsh中历史记录的最后n行。