When i type something like this:
$ complete -p | grep -ie '\<man\>'
or:
$ find /etc/bash_completion.d/ -iname '*man*'
or:
$ grep -rie '\<man\>' /etc/bash_completion.d/
I don't find any trace of the complete
function for the man
command!
The goal is to add this completion for one of my own-made function:
complete -F <the_man_complete_function> <my_man_related_command>
Any idea?
I found a solution : to load the not-yet-loaded completion func, I just have to launch this in .bashrc
:
. /usr/share/bash-completion/completions/man
Usefull links that helped me:
EDIT
To avoid loading the man completion script on every bash session start, a better solution is to write a local completion script, to put in the directory $XDG_DATA_HOME/bash-completion/completions
(typically ~/.local/share/bash-completion/completions
), with the name of the desired command (as explained in the bash-completion FAQ).
Here's the code I put in the script (named myman
):
#!/bin/bash
# Force the load of the man completion function if it is not loaded yet:
type -t _man >/dev/null || . /usr/share/bash-completion/completions/man
complete -F _man myman
With this method, the man completion function will be loaded only when required (by man
, or myman
).