Skip to content

Instantly share code, notes, and snippets.

@tommyvdv
tommyvdv / .bashrc
Last active March 8, 2019 07:45
Make(file) completion
# List make targets since this is not something make can do the way we want it to
list_make_targets() {
file=Makefile && [[ -f "$file" ]] && grep -oE '^[a-zA-Z0-9_.-]+:([^=]|$)' "$file" | sed 's/[^a-zA-Z0-9_.-]*$//' || printf '"%s" not found\n' "$file"
}
# Tell (ba)sh completion to use function "list_make_targets" for completion
make_load_autocomplete() {
complete -W "\`list_make_targets\`" make
}