2

I wrote my auto-completion function for make command, and placed it in ~/.zsh:

function __comp_make {
    # ... function body ....
}
compctl -K __comp_make make

Unfortunately, it will not work because completion for make is already defined in

/usr/share/zsh/functions/Completion/Unix/_make

and apparently it takes precedence over my rule.

I had to rename _make to unused_make so it is not loaded at zsh initialization. It works, but it is rather ugly solution.

My question is: how should I set my completion rule so it takes precedence over the loaded defaults?

Related:

Edit:

  • zsh 4.3.17
4

1 回答 1

4

你需要设置你的fpath. 见这里

在您的~/.zshrc中,类似:

fpath=( ~/.zshfunctions $fpath )

where~/.zshfunctions包含您的自定义完成文件,应该为您解决这个问题。请注意,您的函数在系统函数之前加载。这将不起作用

fpath=( $fpath ~/.zshfunctions ) 

顺便说一句,您正在使用compctl. 它是旧的。我建议compsys改用,尽管一个不错的链接解释了为什么我现在不知道。

这些详细介绍了编写完成函数,包括fpath. 您可能会发现它们对参考很有用。

于 2013-08-01T03:34:07.837 回答