Basic bash completion for man command.
- Known manual page names
manoptions
More could be added especially for the options for each flag but I rarely use them.
Either have this inside your ~/.bashrc or save it somewhere and source it in your ~/.bashrc
#!/bin/bash
_man ()
{
local CWORD
CWORD="${COMP_WORDS[COMP_CWORD]}"
# printf 'current word "%s"\n' "$CWORD" # For debugging
case "$CWORD" in
-* ) readarray -t COMPREPLY < <(man --help | grep -oP '\-[\w?\-]+');;
*) readarray -t COMPREPLY < <(man -k . | sed -n "/^$CWORD/ s/ .*//p");;
esac
}
complete -F _man man