3

I put the function

make_color() {
    make $1 | ccze -A
}

in .bashrc to get colored make output. His works fine, but make's tab-completion for selecting targets is lost. Is there any way to preserve the tab-completion of the command in the function, or something else I could do to achieve tab completion and pipe?

Jonatan Öström
  • 2,428
  • 1
  • 16
  • 27

1 Answers1

2

Add this in your ~/.bashrc or run in your local shell:

complete -F _make make_color 

The function name _make may be different in your case. You can get the name using:

$ complete -p make
complete -F _make make
anishsane
  • 20,270
  • 5
  • 40
  • 73
  • Hm, _make didn't work and for some reason `complete -p make` returns `bash: complete: make: no completion specification`. Any Ideas? – Jonatan Öström Jun 04 '19 at 22:09
  • Sometimes, bash loads it at run time. Type `make`. at THIS point bash loads some completion routines. After that, `complete -p make` would work. and `complete -F _make make_color` should work too. – anishsane Jun 05 '19 at 06:12
  • After `make` the command `complete -p make` worked! But still no luck with the completion of `make_color`. After a few tabs the terminal is frozen for a while, so SOMETHING is going on at least. – Jonatan Öström Jan 21 '22 at 21:05
  • It's lazy loading of the completion. Instead of loading all the shell completion at the start, bash has a way to load them on-demand. There is a way to force load a completion without having to press `make`. I had it in some file. I misplaced it. – anishsane Jan 24 '22 at 11:11