Created
January 10, 2017 09:49
-
-
Save gonzalo-bulnes/a05aac06770441d02a5fc9d5df4802ce to your computer and use it in GitHub Desktop.
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
# Provide autocompletion for a Makefile targets. | |
# | |
# Usage: | |
# source .bash_completion # this file | |
# make[tab] # autocompletes the .PHONY targets :) | |
# | |
# See https://debian-administration.org/article/317/An_introduction_to_bash_completion_part_2 | |
_make() | |
{ | |
local cur prev opts | |
COMPREPLY=() | |
cur="${COMP_WORDS[COMP_CWORD]}" | |
prev="${COMP_WORDS[COMP_CWORD-1]}" | |
# autocomplete all the .PHONY targets, improvements are welcome! | |
opts=$(cat Makefile | grep PHONY | awk '{$1=""; print $0;}') | |
if [[ ${cur} == * ]] ; then | |
COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) ) | |
return 0 | |
fi | |
} | |
complete -F _make make |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment