-1

Following on from this question:

bash-function-preserving-tab-completion

It shows that by adding into .bashrc:

mj() {
    make -j10 $@
}
complete -F _make mj

When I run mj <tab> I get "function _make not found"

But then when I run make <tab> (which loads the completion for make) then when I run mj <tab> it works fine.

So how can I force make completion to load withouth having to manually type make <tab> first?

code_fodder
  • 15,263
  • 17
  • 90
  • 167
  • Here `make` is the command or you have a wrapper written over the command to build files? – Inian Jun 26 '19 at 07:00
  • @Inian My new command (function) in .bashrc is `mj` which itself calls `make` inside. The problem appears to be that make's completion function only gets loaded once you run `make + tab` i.e. when you invoke make's tab-completion. Until you do that the function `_make` is not defined so my line `compete -F _make mj` fails until `_make` has been defined (or sourced?). I want to know how I can force this in side bashrc (or elsewhere) so that I don't have to do it manually... does that answer your question? (the wrapper is the function `mj()`) – code_fodder Jun 26 '19 at 07:05

1 Answers1

0

To have completion functions working they must be loaded in your profile first. Something like:

if [ -r /usr/share/bash-completion/bash_completion ]; then
    . /usr/share/bash-completion/bash_completion
fi

Also make sure that shopt -q progcomp is true, and completion script for make (/usr/share/bash-completion/completions/make) exists on your computer.

Matt
  • 13,674
  • 1
  • 18
  • 27