I try to add a completion for the alias: alias m='man'.
So, I added complete -F _man m to my .bashrc.
The problem is that the function _man used for completing, isn't defined at the start of the bash session but is defined when performing the first tab-competition on the $ man command.
So:
$ complete -p | grep _man can either return nothing, or return:
complete -F _man man
complete -F _man apropos
complete -F _man whatis
Therefore, when I try to tab-complete on $ m command, I can get:
$ m -bash: completing : function « _man » not found
$ m
And I have the same problem with the functions _aptitude and _apt-get
What I would like, is to use my .bashrc to force the creation of the functions _man, _aptitude, _apt-get as soon as bash starts.
Maybe it is possible using compgen builtin.
My bash version is:
GNU bash, version 4.2.45(1)-release (x86_64-pc-linux-gnu)
Thanks for reading.
Edit: In fact, a similar question already exists and has been answered:
- bash-completion - completion function defined the first time a command is invoked -