Skip to content

pksublime/zsh-make-completion

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 

Repository files navigation

zsh-make-completion

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)

  1. 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
  1. Add zsh-make-completion to the plugins array in your .zshrc:
   plugins=(... zsh-make-completion)
  1. Reload your shell:
   exec zsh

Manual

  1. Copy zsh-make-completion.plugin.zsh to ~/.zsh/make-completion.zsh (or any path you prefer).

  2. Add the following to your .zshrc after the compinit call:

   [[ -f ~/.zsh/make-completion.zsh ]] && source ~/.zsh/make-completion.zsh
  1. 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 compinit loaded
  • make (GNU Make)
  • awk, sort, cksum (standard on macOS and Linux)

License

MIT License — Copyright (c) 2026 Patrick Little

About

Make zsh behave much like bash when tab completing make targets

Topics

Resources

License

Stars

Watchers

Forks

Contributors

Languages