Last active
March 8, 2019 07:45
-
-
Save tommyvdv/7aa4ca917d26f589ab7766b076493723 to your computer and use it in GitHub Desktop.
Make(file) completion
This file contains 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
# 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 | |
} | |
# Add an alias because we can | |
alias listmake=list_make_targets |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment