I'm preparing a makefile for converting org files to markdown files with the use of pandoc. Its content looks like this (note that conversion rule is just for a reference):

%.md: %.org 
    pandoc -t markdown -s $< -o $@ 

    pandoc -t markdown -s aa.org -o aa.md

Both rules work. For example, I can run:

make aa.md


make conversion

with success. What is more, in bash I can expand:

make con\Tab 

with a Tab key to have conversion autocompleted. However it'd be convenient to have autocompletion also for filenames. So I'd like to have something like this: assuming, that in the same folder there is a file named filefortest.org I write in a bash:

make ./fil\Tab

and voila! I have filefortest autocompleted. Is it possible to achieve this?

PS. I know that the functionality I'm asking for can be easily obtained with simple bash script: pandoc -t markdown -s $1.org -o $1.md. So the question is out of my curiosity....

  • is the #!/bin/bash line in your makefile an accident? Sep 9, 2022 at 10:08
  • Indeed, it's an artifact from my previous experiments. I edited the post and removed it. However, having this line or not does not change anything, does it? Sep 9, 2022 at 10:16
  • I don't know! My shell (admittedly, not a bash) should complete your examples, as far as I remember the completion script Sep 9, 2022 at 10:19
  • nope, won't do it, either. Just for reference, git clone https://gist.github.com/f059ce2fe275447c58b1a276e1409956.git makefile-testing Sep 9, 2022 at 10:25
  • Thanks. I've already installed zsh to try it out but my first attempts failed. Now I can uninstall it with a clear conscience ;) Sep 9, 2022 at 10:30

1 Answer 1


Yes and no.

The bash autocompletion looks inside the makefile, reads targets in it and use them for the possible choices. The only problem in this case - it reads only a clearly defined targets. The patterned ones are ignored.

So there are two ways to achieve what you want:

  1. Manually define each individual file, instead of using %.md: %.org pattern.
  2. Use CMake or some of its cousins which would create a detailed makefile for you.
  • Solution 1) is not what I'm looking for -- the name of the file is supposed to be a parameter, solution 2) is yet another yak shaving for me at this moment. I suppose I'll stick to the bash script approach... Sep 9, 2022 at 14:42

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .