by naggie · 6y ago · 0 comments
See https://github.com/naggie/dotfiles/blob/master/home/.functio...
One of my most useful changes is a script that garbage-collects my history file: deduplication, removal of sensitive + trivial commands. In combination with a FZF based history search that's shared between all shells, I effectively have a super-quick database of every command without any noise. See https://github.com/naggie/dotfiles/blob/master/scripts/clean... -- added via bash/zsh hooks.
There is also a similar builtin feature [1] of ZSH. For example, you can put this in your .zshrc:
REPORTTIME=10
It instructs ZSH to report the time elapsed since the command was invoked (if it is above this threshold, 10 seconds in this case).
However, it just takes the CPU time into account. When using something like `sleep`, it won't trigger. There is a plugin [2] that covers this use case aswell.[1]: https://nuclearsquid.com/writings/reporttime-in-zsh/ [2]: https://github.com/popstas/zsh-command-time
In addition, I can do it in such a way that the most recent invocation is deleted last. I can also use regexes.
See https://github.com/naggie/dotfiles/blob/master/scripts/clean... for more reasoning.