Stop ZSH from trying to correct ssh to .ssh as an argument

autocorrectionzsh

This isn't exactly a duplicate, as I want correct_all still active. I do mess up arguments from time to time and ZSH is happy to help me. The rub happens when I am in my home directory and I want to manage sshd with something like systemctl reload ssh or service ssh start it always asks me if I want to correct to .ssh. I usually perform my work in $HOME so this gets rather annoying. I have already tried alias ssh='nocorrect ssh' and alias ssh='nocorrectall ssh' (which I don't think does anything). Any ideas on how to solve this?

Best Answer

Set CORRECT_IGNORE_FILE. For example to ignore corrections on all dot files:

$ cd
$ PS1='%% ' zsh -f
% setopt CORRECT_ALL
% touch ssh
zsh: correct 'ssh' to '.ssh' [nyae]? a
% CORRECT_IGNORE_FILE='.*'
% touch ssh
% rm ssh

This is documented in 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.

this requires a somewhat recent version of zsh (one more recent than ships with Centos 7). If you're stuck on an old version of zsh you'll need to either disable CORRECT_ALL or use nocorrect to turn the corrections off for each problematical command (which is probably why CORRECT_IGNORE_FILE was added).

Related Question