Skip to content

Instantly share code, notes, and snippets.

@iberianpig
Last active March 15, 2019 07:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save iberianpig/c1f63d1f5bc48ddb9405840e7fb75518 to your computer and use it in GitHub Desktop.
Save iberianpig/c1f63d1f5bc48ddb9405840e7fb75518 to your computer and use it in GitHub Desktop.
`makef` override original ./Makefile with $MAKEF_PATH
function makef() {
make -f "$(makef_path)" "$@"
}
_makef()
{
COMPREPLY=( $(compgen -W "$(grep -oE '^[a-zA-Z0-9_-]+:([^=]|$)' "$(makef_path)" | sed 's/[^a-zA-Z0-9_.-]*$//')" $2) )
}
complete -F _makef makef
makef_path()
{
local path
if [ -a "$MAKEF_PATH" ]; then
if [ -a ./Makefile ]; then
path=$(tempfile)
cat ./Makefile "$MAKEF_PATH" > "$path"
else
path="$MAKEF_PATH"
fi
elif [ -a ./Makefile ]; then
path="./Makefile"
fi
echo $path
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment