Answers:
如果我说得对,那么只有在您使用表单时才会出现这种情况rake test ...
。然后你可以使用这个补丁$fpath/_rake
diff --git a/Completion/Unix/Command/_rake b/Completion/Unix/Command/_rake
index 7fed949..96ee930 100644
--- a/Completion/Unix/Command/_rake
+++ b/Completion/Unix/Command/_rake
@@ -37,12 +37,16 @@ case "$state" in
;;
target)
local -a targets
- targets=( ${${(f)"$(_call_program targets $words[1] -sT $opt_args[(I)(-N|--nosearch)] ${(kv)opt_args[(I)(-f|--rakefile)]} 2>/dev/null)"}/(#b)rake ([^ ]##) ##\# (*)/${${match[1]}//:/\\:}:${match[2]:l}} )
- if (( ! ${targets[(I)rake aborted!]} )) then
- _describe -t targets 'rake target' targets && ret=0
- else
- _message -e targets 'rake target'
- fi
+ if [[ $words[$((CURRENT-1))] == "test" ]]; then
+ _files && ret=0
+ else
+ targets=( ${${(f)"$(_call_program targets $words[1] -sT $opt_args[(I)(-N|--nosearch)] ${(kv)opt_args[(I)(-f|--rakefile)]} 2>/dev/null)"}/(#b)rake ([^ ]##) ##\# (*)/${${match[1]}//:/\\:}:${match[2]:l}} )
+ if (( ! ${targets[(I)rake aborted!]} )) then
+ _describe -t targets 'rake target' targets && ret=0
+ else
+ _message -e targets 'rake target'
+ fi
+ fi
;;
esac
该补丁原则上添加了if [[ $words[$((CURRENT-1))] == "test" ]];
检查前一个参数是否等于“test”的条件。如果是这样,文件和目录将通过_files
函数而不是rake目标返回。
rake
,因此无法判断它是否只针对特殊情况或一般意义上的问题。
/usr/share/zsh/5.0.5/functions/_rake
(/usr/share/zsh/5.0.2/functions/_rake
在OS X Mavericks上)