我读了文档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来显示最后几行。
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 -s或fc -R,则默认last为-l包括由于本次活动开始所有新的历史记录条目。当
-l给定标志,则所得的事件都被列在标准输出。
因此运行:
history -<n>
Run Code Online (Sandbox Code Playgroud)
用连字符号减,如中所示history -16,以查看zsh中历史记录的最后n行。