%20%E5%8E%86%E5%8F%B2%E8%AE%B0%E5%BD%95%E4%B8%AD%E6%98%BE%E7%A4%BA%E4%B8%80%E5%AF%B9%E9%87%8D%E5%A4%8D%E9%A1%B9%EF%BC%9F.png)
我的默认 shell 是zsh
,假设我的历史记录如下所示:
command a
command b
command a
command b
command c
command b
command a
command b
command a
command b
现在我想要的是这样的:
command a
command b
command c
command b
command a
command b
最理想的是,这可以通过根本不存储重复的命令对来实现,但是如果有一种方法可以像我希望的那样显示它grep
,我也完全同意。
答案1
您需要训练自己以不同的方式输入命令,才能获得您想要的结果。这有效:
% setopt histignoredups
% print a; print b
a
b
% print a; print b
a
b
% print a; print c
a
c
% print a; print b
a
b
% print a; print b
a
b
% history
1 setopt histignoredups
2 print a; print b
3 print a; print c
4 print a; print b
%
否则,Zsh 无法知道您所认为的“对”。