From cb5a3fd9a1db2acfe5fafc98a7d82a32a07f23d2 Mon Sep 17 00:00:00 2001 From: Johannes Altmanninger Date: Tue, 5 Oct 2021 21:27:18 +0200 Subject: [PATCH] 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 /. --- share/completions/man.fish | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/share/completions/man.fish b/share/completions/man.fish index dd749c5fb..993a5f0c7 100644 --- a/share/completions/man.fish +++ b/share/completions/man.fish @@ -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