ZSH:如何禁用`make`的默认完成? [英] ZSH: How to disable default completion for `make`?

查看:27
本文介绍了ZSH:如何禁用`make`的默认完成?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我为 make 命令编写了我的自动完成功能,并将其放置在 ~/.zsh 中:

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

function __comp_make {
    # ... function body ....
}
compctl -K __comp_make 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.

我不得不将 _make 重命名为 unused_make 以便它不会在 zsh 初始化时加载.它有效,但它是相当丑陋的解决方案.

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?

相关:

  • zsh 4.3.17

推荐答案

你需要设置你的fpath.请参阅此处.

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

fpath=( ~/.zshfunctions $fpath )

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

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 ) 

顺便说一句,您正在使用 compctl.它老了.我建议改用 compsys ,尽管一个很好的链接解释了为什么现在让我逃脱.

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.

这些是关于编写完成函数的一些细节,包括 fpath.您可能会发现它们可供参考.

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

这篇关于ZSH:如何禁用`make`的默认完成?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆