zsh-make-completion
March 19, 2026 ยท View on GitHub
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.
How it works
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.
Filtered from results
- Pattern rules containing
% - Make variables leaking through as targets (
VAR :=,VAR ?=, etc.) - Special targets beginning with
. - Unexpanded template bodies containing
$ - Targets containing whitespace
Installation
oh-my-zsh (recommended)
- 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
Manual
-
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 zsh
Cache
Completion 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/*
Requirements
- zsh with
compinitloaded make(GNU Make)awk,sort,cksum(standard on macOS and Linux)
License
MIT License โ Copyright (c) 2026 Patrick Little