Run Code Online (Sandbox Code Playgroud)HIST_FIND_NO_DUPS When searching for history entries in the line editor, do not display duplicates of a line previously found, even if the duplicates are not contiguous.
但是,当我重复使用 Ctrl-p 时,会出现相同的命令。
$ ls
$ pwd
$ ls
$ <Ctrl-p> => ls
<Ctrl-p> => pwd
<Ctrl-p> => ls again!
Run Code Online (Sandbox Code Playgroud)
zsh 5.0.5 (x86_64-apple-darwin14.0)
小智 7
hist_find_no_dups 不保证所有行都是唯一的,您可能正在搜索重复的行对。
如果您不想有重复的行,请查看hist_ignore_all_dups. 它会阻止重复的命令出现在您的历史文件中,但它可能会引入意想不到的间隙 - 如果您要重用部分历史记录,则需要注意这一点。
另一个需要研究的选项是hist_ignore_dups. 这可以防止保存连续的重复项。
最后但并非最不重要的是hist_save_no_dups(在写入历史文件时忽略重复项)和hist_expire_dups_first,当$HISTSIZE达到限制时,它将开始删除重复命令。