I love the autocorrection feature of ZSH, but sometimes it gets in the way:

  • If I have a cli directory, it will be suggested when I try to run npm run ci.
  • When running the Docker command docker run -v /some/dir:/var/www it will try to autocorrect to /some/dir/var/www
  • ... and many more

Now I don't want to turn off autocorrection or prefix the command with nocorrect. What I would like is more of a "learning" autocorrection that wraps around the normal suggestions, counts how many times I said "no" to a suggestion and does not suggest it any more if I've said "no" for 3 times. I something like this possible?


1 Answer 1


No, it's not possible. You can use $CORRECT_IGNORE and $CORRECT_IGNORE_FILE to tell Zsh to not suggest certain corrections, but you cannot tell Zsh to not correct certain inputs. So, there wouldn't even be a point in trying to write a function that would collect all words that should not be corrected, because there's no of way of communicating this info to Zsh.

You are probably better off using just setopt CORRECT, which corrects misspelled commands only, and not setopt CORRECT_ALL, which attempts to correct all words on the line. You can use unsetopt CORRECT_ALL to unset it, if necessary.

Another alternative would be to use the zsh-hist plugin, which lets you edit your last command line by pressing undo or any previous line from your history with the hist command. This might be a more reliable way of fixing typos.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .