Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

The autocorrection function of zsh is very helpful for me but it does't always gives a proper result.

~$ sudo vim somefile
zsh: correct 'vim' to '.vim' [nyae]? 

Yet what I want is something like the a never option that can stop it to correct commands like those forever.

How can I do this?

share|improve this question
add comment

3 Answers 3

up vote 33 down vote accepted

You can inform zsh that it should not autocorrect on specific commands by aliasing them with the prefix 'nocorrect' in your .zshrc (example here: http://dzen.geekmode.org/wiki/wiki.cgi/-main/ZshConfiguration):

alias vim='nocorrect vim' 

Alternatively -- if this whitelisting process becomes too frustrating -- you can switch autocorrect off entirely with the following in your .zshrc.

For newer versions of zsh use:

 unsetopt correct

for older versions of zsh use:

 unsetopt correct-all

Amended to add: here is a previous discussion on this subject - Exceptions to zsh correctall feature?

share|improve this answer
1  
While this works for when vim command is at the start, but doesn't work for commands such as bundle exec cucumber <some_specific_feature> && bundle exec rspec <some_specific_spec>. I've added an alias for rspec. Any tips? –  Martin Foot Oct 3 '12 at 8:55
    
@MartinFoot: if you use oh-my-zsh the bundler plugin may help you: coderwall.com/p/weixga –  brafales Nov 19 '12 at 16:03
1  
In the new versions unsetopt correct_all changed to unsetopt correct –  antitoxic Apr 3 '13 at 19:58
    
@antitoxic: I wanted to look up what "new version" in terms of version numbers means, but even in today's git checkout (zsh 5.0.2+31433) the zshoptions manpage states for CORRECT_ALL: Try to correct the spelling of all arguments in a line. Furthermore, both man entries for CORRECT and CORRECT_ALL didn't changed at least since 2008. So I am missing your point; can you please explain what you leads to your statement?! –  mpy May 30 '13 at 10:01
    
I'd like to add: load order matters! Make sure you add unsetopt after sourcing oh-my-zsh... Wasted a lot of my time. –  oma Aug 26 '13 at 19:04
show 1 more comment

I think I found a better answer to this.

Im not sure about versions and whatnot, but it seems correct_all is supposed to correct commands and arguments, while correct corrects only commands, therefore eliminating this annoying behaviour.

This is what I have in my config files

unsetopt correct_all  
setopt correct
share|improve this answer
    
This is the actual answer. correct-all doesn't appear to be a real option in any documentation I can find, nor in Real Life. It's correct_all. Thanks! –  Jamey May 23 at 2:10
    
I have setopt correctall from zsh.sourceforge.net/Intro/intro_16.html –  zzapper Jun 6 at 16:15
add comment

I had the problem when using rspec via zeus, and I'd like to keep auto-correct settings as they seem to work for everything else except rspec, so I never tried any of the other suggestions above.

What I had to do was nocorrect zeus itself :

alias zeus='nocorrect zeus'

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.