Command history contains plenty of duplicates usually, and these are just noise. Would be nice to have them removed from the list.
On bash, I can prevent duplicates in the history by setting HISTCONTROL as follows:
export HISTCONTROL=ignoreboth:erasedups
For zsh the equivalent seems to be HIST_IGNORE_ALL_DUPS:
See http://zsh.sourceforge.net/Doc/Release/Options.html
I have ignoredups in my .bashrc, why is erasedups necessary in addition?
@jean This might answer your question: http://askubuntu.com/questions/15926/how-to-avoid-duplicate-entries-in-bash-history
Even after that it won't be perfect, at least in old bash 3.x. People make elaborate PSCMD to deal with it, or just live with it :)
Ah, now I get it. ignoredups prevents cluttering history with runs of the same command, but keeps invocations interleaved with other commands, so that the history reads sensibly. I often copy and edit history to document what I did, so this is helpful (and holes in history caused by deleting previous invocations would be harmful).
I would argue that it does not make sense for fzf to go and gather identical commands sprinkled here and there in the history, because it doesn't show you command context (next/previous commands). It should either show only the most recent match, or at least collapse runs of identical matches.
Yeah, I agree. The decision should be up to the individual user.
And for your information, the default CTRL-R key binding uses +s (or --no-sort) option to keep the order of commands intact and the recent version of fzf allows you to scroll through the result beyond the scope of the screen, so it's pretty nice to browse the history with it.
I'm closing this issue.
I found that bash wasn't removing duplicates very well trying these options, so I made a quick python script to deduplicate history when the bash session ends:
https://github.com/naggie/dotfiles/blob/fzf/bin/cleanup-history.py
Instructions are at the top of the file.
Most helpful comment
Ah, now I get it.
ignoredupsprevents cluttering history with runs of the same command, but keeps invocations interleaved with other commands, so that the history reads sensibly. I often copy and edit history to document what I did, so this is helpful (and holes in history caused by deleting previous invocations would be harmful).I would argue that it does not make sense for
fzfto go and gather identical commands sprinkled here and there in the history, because it doesn't show you command context (next/previous commands). It should either show only the most recent match, or at least collapse runs of identical matches.