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


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.

  • Thanks for the info! Well, I guess I'll have to resort to nocorrect because adjusting correction tags with zstyle is still done per-command, if I understand it correctly. – Mischa Arefiev Apr 10 '12 at 9:13

It sounds to me like you are missing something in your distribution. Most ZSH implementations come with a large collection of pre-configured completion settings for ZSH that intelligently complete based on the command and argument position. For example on my system there is a zsh-completions package. When installed and properly loaded, man completes only with things found in the man pages not with files, ssh only with host names, ssh -l would complete with system usernames, but after ssh -l caleb would then return to completing with host names, etc.

You should look into what zsh packages are available and whether you are loading the default configurations properly. You should not have to setup a bunch of manual over-rides for standard commands such as you list in your question.

  • 1
    Completion of args works: gris@arefiev: ~% man <tab> yields zsh: do you wish to see all 11200 possibilities (5601 lines)? (number of binaries). I am concerned with correction, not completion. It seems like they don't work together. – Mischa Arefiev Apr 9 '12 at 11:56
  • @MischaArefiev: I see your point, and you're right I was on a little different track here. At the same time, my shell behaves differently than yours in the area of autocorrect as well, and I have not configured a bunch of individual over-rides. I can't put my finger on what is different in my setup. – Caleb Apr 9 '12 at 12:26
  • what version of Zsh are you running? – Mischa Arefiev Apr 9 '12 at 13:12
  • Last I looked it was 4.3 something but point releases are frequent and this behavior has been consistent for me for quite some time, do I would suspect configuration, but version... – Caleb Apr 9 '12 at 13:27
  • The problem here is with correction options, not completion. – Kevin Apr 10 '12 at 1:38

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.