Shell – Zsh — more intelligent autocorrection

shellzsh

Is it possible to make Zsh stop trying to correct arguments that are not meant to be files with files from the current directory without turning off correction completely or limiting it to setopt CORRECT (only correct the command)?

For example, when CORRECT_ALL is set with setopt, this happens:

 gris@arefiev: ~% cd srcc 
change srcc to src-nyae? n

So far, good (argument to cd should be a file). However,

 gris@arefiev: ~% man zile
change zile to .zile-nyae? 

What? I would expect it to correct zile to .zile when man is called with -C option. It also tries to correct host parameters of ssh, first arguments to sudo etc which gets really annoying.

I have to resort to a crutch: set alias man='nocorrect man' etc etc, for every affected command, but clearly it's not the best solution. I also don't like CORRECT and would prefer the crutch plus CORRECT_ALL to just CORRECT.

Zsh is zsh 4.3.17 (x86_64-unknown-linux-gnu), Debian sid.

Update: here is my .zshrc http://pastebin.com/67mykgRv

Best Answer

Zsh comes with a large set of completions but a smaller set of corrections. There are many commands for which completion is useful but not correction; for example, it's useful to complete arguments to mkdir (to create directories inside existing directories) but not to correct them. The correct_all option is very harsh, as it turns on correction everywhere; unfortunately, there is no option to correct only when a set of correct inputs is supplied.

You can customize the corrections for a given command by setting the corrections tag, and customize whether to perform correction by making _correct part of the matcher-list or not. These are set with the zstyle builtin.

Related Question