如何使用 hist_ignore_dups 忽略 zsh 中启用 Extended_history 的重复行?

cur*_*oky 8 zsh

当启用hist_ignore_dupsin时zsh,我发现 中有很多重复的行$HISTFILE

(笔记:HISTFILE="$HOME/.zsh_history"

$ cat $HISTFILE

: 1593874281:0;ls
: 1593874287:0;l
: 1593874288:0;ls
: 1593874291:0;l
Run Code Online (Sandbox Code Playgroud)

我认为hist_ignore_dups应该解决这个问题。(HIST_IGNORE_DUPS http://zsh.sourceforge.net/Doc/Release/Options.html)。

但是重复的行仍然出现在 中$HISTFILE,即使已经通过历史记录hist_ignore_dups插件启用了。ohmyzsh

## History command configuration
setopt extended_history       # record timestamp of command in HISTFILE
setopt hist_expire_dups_first # delete duplicates first when HISTFILE size exceeds HISTSIZE
setopt hist_ignore_dups       # ignore duplicated commands history list
setopt hist_ignore_space      # ignore commands that start with space
setopt hist_verify            # show command with history expansion to user before running it
setopt share_history          # share command history data
Run Code Online (Sandbox Code Playgroud)

我怀疑这一点extended_history并且hist_ignore_dups存在冲突。

Mar*_*ert 14

根据文档

\n
\n
\n

HIST_IGNORE_DUPS( -h)

如果命令行与前一个事件重复,请勿将其输入到历史列表中。

\n

\n

请注意,这是“前一个”事件,而不是“任何”之前的事件。

\n

如果你想忽略所有重复项,则需要设置\xe2\x80\xa6

\n

击鼓

\n

你猜到了:HIST_IGNORE_ALL_DUPS

\n

文档中中:

\n
\n
\n

HIST_IGNORE_ALL_DUPS

如果添加到历史列表中的新命令行与旧命令重复,则旧命令将从列表中删除(即使它不是上一个事件)。

\n

\n