阻止 ZSH 尝试将 ssh 更正为 .ssh 作为参数

use*_*470 5 zsh autocorrection

这并不完全是重复的,因为我希望正确的_all 仍然有效。我确实不时搞砸了争论,ZSH 很乐意帮助我。当我在我的主目录中并且我想用类似的东西管理 sshdsystemctl reload ssh或者service ssh start它总是问我是否要更正到.ssh. 我通常执行我的工作,$HOME所以这会很烦人。我已经尝试过alias ssh='nocorrect ssh'并且alias ssh='nocorrectall ssh'(我认为它没有任何作用)。关于如何解决这个问题的任何想法?

thr*_*rig 7

设置CORRECT_IGNORE_FILE。例如忽略对所有点文件的更正:

$ cd
$ PS1='%% ' zsh -f
% setopt CORRECT_ALL
% touch ssh
zsh: correct 'ssh' to '.ssh' [nyae]? a
% CORRECT_IGNORE_FILE='.*'
% touch ssh
% rm ssh
Run Code Online (Sandbox Code Playgroud)

这是记录在 zshall(1)

   CORRECT_IGNORE_FILE
          If set, is treated as a pattern during  spelling  correction  of
          file  names.   Any  file  name that matches the pattern is never
          offered as a correction.  For example, if the value is `.*' then
          dot  file  names  will never be offered as spelling corrections.
          This is useful with the CORRECT_ALL option.
Run Code Online (Sandbox Code Playgroud)

这需要一个较新的版本zsh(比 Centos 7 附带的版本更新)。如果您坚持使用旧版本,则zsh需要禁用CORRECT_ALL或使用nocorrect来关闭每个有问题的命令的更正(这可能CORRECT_IGNORE_FILE是添加的原因)。