240

I run the following command unsuccessfully

dir

and I get

zsh: correct 'dir' to 'gdir' [nyae]? 

What does [nyae] mean in Zsh?

vlasits
  • 2,215
  • 1
  • 15
  • 27
Léo Léopold Hertz 준영
  • 134,464
  • 179
  • 445
  • 697
  • 4
    BTW: you might want to alias `dir` to `ls -l`, then zsh wont auto correct it anymore and you get your expected results. – eckes Aug 10 '14 at 00:54

3 Answers3

324

zsh has a powerful correction mechanism. If you type a command in the wrong way it suggests corrections. What happend here is that dir is an unknown command and zsh suggests gdir, while maybe ls was what you wanted.

  1. If you want to execute gdir hit y (yes)
  2. If you want to try to execute dir anyway hit n (no)
  3. If you want to execute completely different spelt command like ls hit a (abort) and type your command
  4. If you want to execute a similar spelt commant like udir hit e (edit) and edit your command.
Ludwig Weinzierl
  • 15,980
  • 10
  • 45
  • 49
  • 81
    Wish there was an extra key option that made nocorrect easier, like [nyaei] - i = ignore forever! – manafire Sep 21 '13 at 20:51
  • 70
    I came here because I thought that `a` would mean "always". I wish it mean that. – Rafael Eyng Dec 17 '15 at 12:54
  • 5
    I actually hoped for the same as @RafaelEyng, but I now have the following line in my .zshrc: `alias gti=git`. Permanent autocorrection ^^ (Yes, I have actually misspelled git far too often to bear it) – xeruf Feb 09 '19 at 09:12
  • 1
    I was sure that `a` is always and `e` is never (as its second letter, as `n` is already no). TIL. – hans Dec 14 '20 at 14:31
  • @RafaelEyng Same here, but you can at least disable the feature manually https://superuser.com/questions/439209/how-to-partially-disable-the-zshs-autocorrect – RCross Jan 06 '23 at 08:24
159

A quick reference:

$ dir
zsh: correct 'dir' to 'gdir' [nyae]?
  • n: no – don’t correct; run dir, as you typed
  • y: yes – do correct; run gdir, as Zsh suggested
  • a: abort – don’t run anything, and get a new prompt (to type a completely different command)
  • e: edit – edit what you typed interactively – for instance, so you can change dir to udir
Rory O'Kane
  • 29,210
  • 11
  • 96
  • 131
  • 25
    I based this answer off of [Ludwig’s explanation](http://stackoverflow.com/a/800196/578288), but wrote it in a shorter format. This format is better-suited to those who have already guessed how Z shell corrections work, and merely want to know what each option does. – Rory O'Kane Sep 07 '12 at 21:19
  • pretty clear!, is there a good introduction to zsh use? I found that zsh documentation is like 500+ pages, and I wanna know basic usage and regex. – mao2047 Oct 26 '20 at 23:29
46

From An Introduction to the Z Shell:

If you press y when the shell asks you if you want to correct a word, it will be corrected. If you press n, it will be left alone. Pressing a aborts the command, and pressing e brings the line up for editing again, in case you agree the word is spelled wrong but you don’t like the correction.

Alnitak
  • 334,560
  • 70
  • 407
  • 495