Skip to content

Instantly share code, notes, and snippets.

@tlrobinson
Created July 9, 2011 19:34
Show Gist options
  • Save tlrobinson/1073865 to your computer and use it in GitHub Desktop.
Save tlrobinson/1073865 to your computer and use it in GitHub Desktop.
Autocomplete Makefile targets. Add this to your shell config file.
complete -W "\`grep -oE '^[a-zA-Z0-9_-]+:([^=]|$)' Makefile | sed 's/[^a-zA-Z0-9_-]*$//'\`" make
@perenecabuto
Copy link

complete -W "test -e Makefile && grep -oE '^[a-zA-Z0-9_-]+:([^=]|$)' Makefile | sed 's/[^a-zA-Z0-9_-]*$//'" make

To avoid errors on folder without Makefile

@hxgdzyuyi
Copy link

it's broken when Makefile include other makefile

@slava-konashkov
Copy link

slava-konashkov commented Nov 11, 2022

complete -W "`make -qp | sed -n -E 's/^([^.#\s][^:=])(:$|:\s+.$)/\1/p' | sort -u'`" make

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment