I have an alias for

alias tdA='todo -a'

I get the following in Zsh

zsh: correct 'tdA' to 'tda' [nyae]? 

How can you make Zsh not to suggest a fix for an alias?

  • I don't use ZSH (yet) so this may be a dumb question, but are you sure the alias is loaded in? – Hofa Jun 7 '09 at 15:18
  • @Hofa: It is loaded, since I can use it. – Léo Léopold Hertz 준영 Jun 7 '09 at 15:33


% unsetopt correct

I have the spelling correction off by default.

If it works, add it to your .zshrc file.

  • @Roy: Thank you for your answer! This seems to be the best solution. – Léo Léopold Hertz 준영 Jun 7 '09 at 15:36
  • @masi - please see my answer instead. I do not believe this answer to be the ideal solution for you. – Larold Sep 15 '11 at 1:29
  • Larold's answer is preferable – Cory Mar 13 '12 at 17:00

I've been using zsh for about 18 years now, and I must say I don't like the accepted solution. Here's why:

You need to figure out the source of the problem - determine why 'tda' is being offered as a correction option. What you have done is completely disabled spelling correction globally. This denies you some very nice functionality while trying to get rid of a tactical problem. It's like wanting to kill a fly in your house by setting off some dynamite just because you're too lazy to figure out where the fly swatter is: It may get rid of the problem, but you sacrifice a whole lot in return. :)

Until you can determine your zsh's current spell correction configuration, you should consider setting the value of the special shell variable $CORRECT_IGNORE to a value of 'tda'.

Here is the entry in the zsh man page:

          If set, is treated as a pattern during spelling correction.  Any
          potential  correction  that matches the pattern is ignored.  For
          example, if the value is `_*' then completion functions  (which,
          by  convention,  have  names  beginning  with `_') will never be
          offered as spelling corrections.  The pattern does not apply the
          correction  of  file names, as applied by the CORRECT_ALL option
          (so with the example just given files beginning with `_' in  the
          current directory would still be completed).

This should help get you by until you can determine the source of where 'tda' is actually coming from.

Also note that you can use the precommand modifier 'nocorrect' to disable spelling correction on a per-command basis. You could use this to do something a little hacky, but effective:

alias tdA="nocorrect tda"
alias tda="todo -a"

aliases are just tokens substituted into the command-line by zsh, and those substitutions are re-scanned for additional aliases. So the above should work.

Hopefully these alternatives give you a more selective approach to solving your problem, while still giving you the benefit of zsh's rich spelling correction features.

Good luck!

  • +1, spelling correction is great, no reason to turn if off altogether. – seth Sep 14 '11 at 20:20

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.