Skip to content

Instantly share code, notes, and snippets.

@WoozyMasta
Created August 28, 2025 10:34
Show Gist options
  • Select an option

  • Save WoozyMasta/41e100f81420e3468e474685ce607e89 to your computer and use it in GitHub Desktop.

Select an option

Save WoozyMasta/41e100f81420e3468e474685ce607e89 to your computer and use it in GitHub Desktop.
makefile bash completion
# makefile completion
function __makefile_completion() {
[ ! -f "${1:?}" ] && return
grep -oE '^[a-zA-Z0-9_.-]+:([^=]|$)' "$1" | sed 's/[^a-zA-Z0-9_.-]*$//' | grep -iv '.phony'
while read -r x; do
__makefile_completion "$(envsubst <<< "$x")"
done < <(grep -E '^include' "$1" | sed -e 's/include //' -e 's/(/{/' -e 's/)/}/')
}
complete -W "\$(__makefile_completion ?akefile)" make
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment