Search code examples
makefilebash-completion

bash completion of makefile target


Suppose I have a simple makefile like:

hello:
   echo "hello world"

bye:
   echo "bye bye"

Then in bash I want something like:

make h < tab >

so it can complete to

make hello

I found a simple way like creating empty files hello and bye but I'm looking for something more sophisticated.


Solution

  • This answer from 2010 is outdated - the project mentioned here seems to have been discontinued.

    Could this be what you're looking for?

    http://freshmeat.net/projects/bashcompletion/

    make [Tab] would complete on all targets in Makefile. This project was conceived to produce programmable completion routines for the most common Linux/UNIX commands, reducing the amount of typing sysadmins and programmers need to do on a daily basis.