Hi,
Back when I was under 12.1 (we recently migrated to Leap 15 at work), there were a convenient way to have autocompletion to a make alias:
# Make the alias:
alias mj='make -j32 -k'
# Make alias autocompletion
complete -F _make mj
But this does not work with Leap 15, indeed, with same code when typing mj then tab in a console I have the following result:
mj bash: completion: function `_make' not found
After some digging I’ve seen it seems there are some predefined auto completers that matches for make, gmake and others in 12.1:
$ complete -pr | grep make
complete -F _make gnumake
complete -F _filedir_xspec makeinfo
complete -F _automake automake-1.11
complete -F _make make
complete -F _make gmake
complete -F _automake automake
complete -F _make pmake
But they are not present in Leap 15:
$ complete -pr | grep make
complete -F _filedir_xspec makeinfo
Is there a way to have them installed ? And when I try to find from which package comes complete I can’t figure it out:
$ which complete
which: no complete in (/home/octopus/bin:/usr/local/bin:/usr/bin:/bin:/usr/lib/mit/sbin)
I’ve also seen there is bash-completion package installed on both (1.3-3.1.1 on 12.1 and 2.7-lp151.4.1 on Leap 15), I assume this is from were it comes, and on Leap 15 there is an “extra” bash-completion-devel package I installed but it did not change anything.
Anybody knows if it is possible to have autocompletion for make alias on Leap 15 ?
Thanks
Hi,
complete is a shell builtin
type -a complete
you could try finding which is the function value/definition of **_make
**
type -a _make
You can check the package e.g.
rpm -ql bash-completion
Thanks for your answer, checking package with
rpm -ql bash-completion
shows there are completion for some commands that are set in files, for make, in
/usr/share/bash-completion/completions/make
but I don’t know why it does not work for me since it also uses
complete -F _make ...
Anyway, I’ll look into it, thanks again.
Hi,
You can check the change log about the relevant changes/date and who did it.
rpm -q --changelog bash-completion | less
Thanks for this too, I also found another interesting folder around bash completion:
/etc/bash_completion.d/
In which, on 12.1 there is a make file present but not in Leap 15, I then copied it for Leap 15:
sudo cp /usr/share/bash-completion/completions/make /etc/bash_completion.d/.
And then I was able to see
complete -F _make ...
When running
$ complete -pr | grep make
complete -F _make colormake
complete -F _make gmake
complete -F _make gnumake
complete -F _filedir_xspec makeinfo
complete -F _make pmake
complete -F _make make
But after having run
complete -F _make mj
Just nothing happens when I type mj <tab>.
@antoinep:
A quick GFI (Google for it) came up with
which lead me to GitHub - cykerway/complete-alias: automagical shell alias completion;
I have a file named ‘Makefile’ in the current directory with content:
.PHONY: help
help:
<TAB>@echo 'Help text'
(Replace ‘’ with a real -character!)
I did this:
alias mj='make -j32 -k'
# With mj <TAB> I got:
mj Makefile
That is not what you want. The solution:
wget -O- 'https://raw.githubusercontent.com/cykerway/complete-alias/master/complete_alias' >> ~/.complete_alias
# Always check first when getting executable content from the web:
less ~/.complete_alias
. ~/.complete_alias
complete -F _complete_alias mj
# Now with mj <TAB> I got:
mj help
That is the kind of behavior you want.
To make things permanent:
echo 'complete -F _complete_alias mj' >> ~/.bash_completion
cat >> ~/.bashrc <<EOF
. ~/.complete_alias
. ~/.bash_completion
EOF
Kind regards,
Leen