When I am in a directory with Makefile, and I use zsh completion for make:

make <TAB>

it completes two sets of completions:

  1. the targets from the Makefile
  2. files in current directory

I only want 1)

How can I disable 2) ?

I have pasted here the _make completion file: https://ctxt.io/2/AADge23ZFg

  • Just for historical purposes, could you provide permanently your code from ctxt.io/2/AADge23ZFg? It seems that code will be deleted automatically in <30 days.
    – silvioprog
    Aug 23, 2022 at 3:06

1 Answer 1


The completions come from _alternative 'targets:…' 'variables:…' '*:…'.

The _alternative function lists choices between tags. The order and selection of tags can be configured with the tag-order style. The context for the style is :completion::complete:make:: — you can either work this out from the documentation (including that of zstyle, or read it in the trace produced by ^X? (_complete_debug).

To only complete target and variable names, but not file names, as far as I understand, you can set the tag order like this:

zstyle ':completion::complete:make::' tag-order 'targets variables' -

However, experimentally, this offers no completions at all and I can't figure out why.

What does work, however, and is probably more useful, is to set the tag order to prioritize targets and variable names. Then make stuffTab will only try to complete file names if there are no matching targets or variable names.

zstyle ':completion::complete:make::' tag-order 'targets variables'

Or, to ignore variables unless no targets match, and to ignore files unless neither targets nor variables match:

zstyle ':completion::complete:make::' tag-order targets variables

(Oh, and for completeness's sake, you can completely disable all file completion for make arguments with zstyle ':completion::complete:make::' file-patterns ''. But this even disables completions for things like make -f, which unfortunately doesn't have a different context string.)

  • 1
    This command did it for me: zstyle ':completion::complete:make::' tag-order targets variables Feb 6, 2023 at 22:19

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .