zsh-autosuggestions icon indicating copy to clipboard operation
zsh-autosuggestions copied to clipboard

Block certain commands from being added to history

Open TravisGM92 opened this issue 2 years ago • 3 comments

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.

TravisGM92 avatar Jul 14 '23 18:07 TravisGM92

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

  • ls, ls somepath: I did not write ls* because I don't want to ignore all commands starting with the letters ls
  • same for the alias l
  • same for cd, but only for going up and back
  • etc

Does that meet your expectations?

graelo avatar Jul 20 '23 06:07 graelo

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

TravisGM92 avatar Jul 20 '23 13:07 TravisGM92

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

graelo avatar Jul 20 '23 13:07 graelo