zsh: disable default completion for `make`

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-11 12:49:51

问题


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:

  • How does one override an existing zsh keyboard completion?

Edit:

  • zsh 4.3.17

回答1:


You need to set your fpath. See here.

In your ~/.zshrc, something like:

fpath=( ~/.zshfunctions $fpath )

where ~/.zshfunctions contains your custom completion files, should solve this for you. Note that your functions are loaded before the system ones. This will not work:

fpath=( $fpath ~/.zshfunctions ) 

As an aside, you're using compctl. It's old. I'd recommend using compsys instead, although a decent link explaining why escapes me at the moment.

These go into some detail about writing completion functions, including the fpath. You might find them useful for reference.

  • Z-shell completion functions: introduction
  • Writing z-shell completion functions


来源:https://stackoverflow.com/questions/17968024/zsh-disable-default-completion-for-make

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!