无法让Zsh不build议修正别名

我有一个别名

alias tdA='todo -a' 

我在Zsh得到以下内容

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

你怎么能让Zsh不要build议一个别名的修复?

尝试

%unsetopt正确

我默认closures拼写。

如果有效,请将其添加到.zshrc文件中。

我已经使用了zsh大约18年了,我必须说我不喜欢被接受的解决scheme。 原因如下:

你需要找出问题的根源 – 确定为什么“tda”是作为一个修正选项提供的。 你所做的是全面禁用拼写纠正。 这在否定了一些非常好的function的同时,却试图摆脱一个战术问题。 就好像你想要杀掉你家里的苍蝇一样,只是因为你懒得弄清楚苍蝇拍的位置:它可能会摆脱这个问题,但是你却牺牲了很多。 🙂

在您确定您的zsh当前的拼写纠正configuration之前,您应该考虑将特殊shellvariables$ CORRECT_IGNORE的值设置为“tda”的值。

以下是zsh手册页中的条目:

  CORRECT_IGNORE 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). 

这应该能帮助你,直到你能确定“tda”实际来源的来源。

另请注意,您可以使用precommand修饰符'nocorrect'来禁用每个命令的拼写纠正。 你可以用它来做一些有趣的事情,但有效的:

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

别名只是通过zshreplace到命令行中的令牌,并且这些replace将被重新扫描以获取其他别名。 所以上述应该工作。

希望这些替代方法能够给你一个更有select性的方法来解决你的问题,同时还给你zsh丰富的拼写纠正function的好处。

祝你好运!