Reputation: 7078
In zsh (with oh-my-zsh, is that matters) when I enter empty commands (e.g. just press enter) I see empty lines added to my ~/.zsh_history
:
: 1508496422:0;ls
: 1508496422:0;vim
: 1508496482:0;
: 1508496482:0;
: 1508496482:0;
: 1508496482:0;
: 1508496490:0;
: 1508496490:0;
: 1508496490:0;
: 1508496490:0;
: 1508496494:0;ls
I'm wondering if it's possible to avoid adding these lines. I checked http://zsh.sourceforge.net/Doc/Release/Options.html but no luck. The reason why I'm trying to avoid adding empty lines is I'm using fzf and fzf lists these empty commands when I search in last commands in a directory.
If this is not possible in zsh side I'll try to search for a solution in fzf side.
Upvotes: 1
Views: 745
Reputation: 10264
There are a few Zsh settings to control what goes into your history
(though I'm surprised emtpies end up there; I can't reproduce that
despite also using fzf and hitting blank RET
s a lot).
The man page for zshoptions(1)
describes:
HIST_IGNORE_[ALL_]DUPS
— This should at least reduce your
consecutive multiple empties down to one.
HIST_IGNORE_SPACE
— Your empties might be treated as whitespace
and thus be eliminated. I like this feature anyway for intentionall
discarding commands by starting them with a space.
There is also the HISTORY_IGNORE
option (not to be confused with
Bash's HISTIGNORE
) — described in zshparam(1)
with an example —
which lets you remove a set of patterns. An empty pattern may fix
your case. It also has a zshaddhistory
hook that you could use to
more finely control exactly what goes into history.
Upvotes: 2