completions/man: offer file completions when appropriate

Suggest files to "man -l", but only if the "-l" option is supported
(so not on BSD). Technically we should accept multiple files but this
seems good enough.

Also suggest files when the token-at-cursor contains a slash, because
man will treat arguments as file paths if they contain a /.
This commit is contained in:
Johannes Altmanninger 2021-10-05 21:27:18 +02:00
parent 475a2afc40
commit cb5a3fd9a1

View File

@ -34,3 +34,8 @@ complete -xc man -s p -d Preprocessors
complete -c man -s t -d "Format for printing"
complete -c man -s w -l path -d "Only print locations"
complete -c man -s W -d "Only print locations"
complete -c man -n 'string match -q -- "*/*" (commandline -t | string collect)' --force-files
if echo | MANPAGER=cat command man -l - &>/dev/null
complete -c man -s l -l local-file -d "Local file" -r
end