zsh-users / zsh-autosuggestions

Fish-like autosuggestions for zsh
MIT License
30.3k stars 1.85k forks source link

Block certain commands from being added to history #750

Open TravisGM92 opened 11 months ago

TravisGM92 commented 11 months ago

Is your feature request related to a problem? Please describe.

After a long enough time the zsh history file becomes quite bloated, and many commands in the history are ones that are run over and over, i.e.: cd *, ls, etc.

Describe the solution you'd like

It would be great if we could configure autosugestions to not save certain commands.

Describe alternatives you've considered

The only alternative I currently see is going in the zsh_history file and removing the specific commands.

graelo commented 11 months ago

Hi, I use the built-in HISTORY_IGNORE for this:

HISTORY_IGNORE="(l|l *|ls|ls *|cd|cd ..*|cd -|z *|pwd|exit)"

In the above, the following will be ignored

Does that meet your expectations?

TravisGM92 commented 11 months ago

@graelo that doesn't block it from being saved into the local history, right? It just blocks it from being displayed.

graelo commented 11 months ago

Hi @TravisGM92,

With the above, the matched commands do not even make it to the history file.

I guess this is a bit stronger than what you initially had in mind.

PS: Thanks for this repo, this is sooo great