Tuesday, 7 May 2019

autocorrect - Exceptions to zsh correctall feature?


I am using the correctall option in zsh, and I am generally quite happy with it. There are, however, few situations where I find this feature highly annoying.


For example, lets say I have a file file1.tex and I want to create a copy called file2.tex which I will then edit to make some changes. I will do


cp file1.tex file2.tex

only to be told by zsh that I might have misspelled file2.tex and if I want to correct it to file1.tex.


What happens is this: when zsh tries to check spelling, it looks in the current directory for a file called file2.tex, does not find it, but finds file1.tex and assumes that I misspelled file1.tex, and asks me if I want to correct that.


That happens to me so often that I actually unset the correctall option, and use only correct. However, bad typist as I am, I really miss the correctall option. Thus my my question:


Is there any way to tell zsh not to correct the last argument of the cp command?


(I know I could get the result I want by modifying completion settings for cp, but I still want to have completion on the last argument, I just don't want to autocorrect it.)



Answer



Try these.


alias cp='nocorrect cp '
alias mv='nocorrect mv '
alias mkdir='nocorrect mkdir '

etc.


That's not totally on point as it will disable application of correctall for the entire command, but I think it's a good compromise. Completion (including the _correct completer) and expansion, for example, will still work.


No comments:

Post a Comment

How can I VLOOKUP in multiple Excel documents?

I am trying to VLOOKUP reference data with around 400 seperate Excel files. Is it possible to do this in a quick way rather than doing it m...