简体   繁体   中英

Supress correction by argument in zsh

Suppose I have the file tree

-A_dir/
  - a_test_file1

Doing mv a_test_file1 a_test_file2 results in an annoying correction query. The second argument of mv should never be corrected, as it may or may not point to an existing node on the filesystem. However, the first argument may be corrected because it must always be a valid node.

This is an common use case, where I'd only like zsh to correct certain arguments in a command. How can I achieve this?

Placing this as an answer because it is too much text for a comment... but this is really a comment.

Honestly, a cursory reading of the manual indicates that this is not possible without deep hackery. correct corrects commands and correct_all tries to correct all arguments.

I thought about doing something like

function mv {
  emulate -L zsh
  CORRECT_IGNORE='*'$@[-1]'*'
  command mv $@
}

But it does not work as CORRECT_IGNORE does not apply to the correction of filenames. If you could find out how to produce corrections from a list of arguments, you could generate corrections for all arguments that you want corrected and later call nocorrect mv ... .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM