Created
August 28, 2025 10:34
-
-
Save WoozyMasta/41e100f81420e3468e474685ce607e89 to your computer and use it in GitHub Desktop.
makefile bash completion
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # 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