Correct, fast make tab completion for zsh.
The built-in zsh make completion parses Makefile text directly, which misses
targets generated at eval time via patterns like $(eval $(call ...)). It also
surfaces internal make variables as spurious completions. This plugin fixes both.
Tab completion runs make -qp to fully expand the makefile database, then filters
the output with awk to extract only real targets. Results are cached per-directory
and invalidated automatically when Makefile or any *.mk file changes, so
repeated tab presses are instant.
- Pattern rules containing
% - Make variables leaking through as targets (
VAR :=,VAR ?=, etc.) - Special targets beginning with
. - Unexpanded template bodies containing
$ - Targets containing whitespace
- Clone into your oh-my-zsh custom plugins directory:
git clone https://github.com/pksublime/zsh-make-completion \
${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-make-completion- Add
zsh-make-completionto thepluginsarray in your.zshrc:
plugins=(... zsh-make-completion)- Reload your shell:
exec zsh-
Copy
zsh-make-completion.plugin.zshto~/.zsh/make-completion.zsh(or any path you prefer). -
Add the following to your
.zshrcafter thecompinitcall:
[[ -f ~/.zsh/make-completion.zsh ]] && source ~/.zsh/make-completion.zsh- Reload your shell:
exec zshCompletion results are cached in ${XDG_CACHE_HOME:-$HOME/.cache}/zsh-make-completion/,
keyed by a checksum of $PWD. The cache is invalidated when Makefile, makefile,
GNUmakefile, or any *.mk file in the project root or mk/ subdirectory is newer
than the cached result.
To manually clear the cache:
rm ${XDG_CACHE_HOME:-$HOME/.cache}/zsh-make-completion/*- zsh with
compinitloaded make(GNU Make)awk,sort,cksum(standard on macOS and Linux)
MIT License — Copyright (c) 2026 Patrick Little