zsh历史太短 [英] zsh history is too short
问题描述
当我在Bash中运行history
时,我得到了很多结果(超过1000个).但是,当我运行history
zsh shell时,我只会得到15个结果.这使得zsh中的grepping历史几乎毫无用处.
我的.zshrc
文件包含以下几行:
When I run history
in Bash, I get a load of results (1000+). However, when I run history
the zsh shell I only get 15 results. This makes grepping history in zsh mostly useless.
My .zshrc
file contains the following lines:
HISTFILE=~/.zhistory
HISTSIZE=SAVEHIST=10000
setopt sharehistory
setopt extendedhistory
如何修复zsh以使我的shell历史记录更有用?
How can I fix zsh to make my shell history more useful?
更新
如果在zsh中打电话给history 1
,我将获得所有历史记录,就像在Bash中使用history
一样.我可以对该命令进行别名以获得相同的结果,但是我想知道为什么history
在zsh和Bash中的行为不同.
If in zsh I call history 1
I get all of my history, just as I do in Bash with history
. I could alias the command to get the same result, but I wonder why does history
behave differently in zsh and in Bash.
推荐答案
NVaughan(OP)已经在问题的更新中给出了答案: history
在bash
中的行为与在bash
中的行为不同zsh
:
NVaughan (the OP) has already stated the answer in an update to the question: history
behaves differently in bash
than it does in zsh
:
简而言之:
- zsh :
-
history
仅列出 15个最新历史记录条目 -
history 1
列出全部-参见下文.
- zsh:
history
lists only the 15 most recent history entrieshistory 1
lists all - see below.
-
history
列出所有历史记录条目.
history
lists all history entries.
可悲的是,将数字操作数传递给
history
的行为也不同:Sadly, passing a numerical operand to
history
behaves differently, too:- zsh :
-
history <n>
显示所有条目 以<n>
开头-因此,history 1
显示所有条目. - (
history -<n>
-注意-
-显示<n>
最新 项,因此默认行为实际上是history -15
)
- zsh:
history <n>
shows all entries starting with<n>
- therefore,history 1
shows all entries.- (
history -<n>
- note the-
- shows the<n>
most recent entries, so the default behavior is effectivelyhistory -15
)
-
history <n>
显示<n>
最新 条目. - (bash的
history
不支持从中列出条目号;您可以使用fc -l <n>
,但必须存在特定条目<n>
,否则命令失败-参见下文.)
history <n>
shows the<n>
most recent entries.- (bash's
history
doesn't support listing from an entry number; you can usefc -l <n>
, but a specific entry<n>
must exist, otherwise the command fails - see below.)
可选的背景信息:
- 在zsh中,
history
实际上(不是实际上)是fc -l
的别名:请参见man zshbuiltins
- 有关许多与历史相关的功能,请参见
man zshall
- In zsh,
history
is effectively (not actually) an alias forfc -l
: seeman zshbuiltins
- For the many history-related features, see
man zshall
- 请参阅:
man bash
- bash:必须存在特定条目
<fromNum>
. - zsh:只要至少有1个条目位于(显式或隐含)范围内,命令就会成功.
- 因此,
fc -l 1
在zsh中工作以返回所有历史记录条目,而在bash中通常不会,因为条目#1通常不再存在(但是,如上所述,您可以使用history
而不使用参数来列出bash中的所有条目.
- bash: specific entry
<fromNum>
must exist. - zsh: command succeeds as long as least 1 entry falls in the (explicit or implied) range.
- Thus,
fc -l 1
works in zsh to return all history entries, whereas in bash it generally won't, given that entry #1 typically no longer exists (but, as stated, you can usehistory
without arguments to list all entries in bash).
这篇关于zsh历史太短的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
- For the many history-related features, see
- 有关许多与历史相关的功能,请参见
-
-