From 5c95111b0fbe613d7b3c893a67430ab4b4220571 Mon Sep 17 00:00:00 2001 From: druckdev Date: Fri, 15 Jan 2021 12:39:47 +0100 Subject: [PATCH] zsh:func:nvim-man: Fail if no manpage found --- .config/zsh/zshrc.d/40-functions.zsh | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/.config/zsh/zshrc.d/40-functions.zsh b/.config/zsh/zshrc.d/40-functions.zsh index d84aeed..462ad21 100644 --- a/.config/zsh/zshrc.d/40-functions.zsh +++ b/.config/zsh/zshrc.d/40-functions.zsh @@ -365,9 +365,13 @@ git-commit-last-msg() { } nvim-man() { - if (( $+commands[nvim] )); then + # Check for existence of man page. Assume that the page was specified as the + # last argument. + command man --where "${@[$#]}" >/dev/null || return + + if (( $+commands[nvim] )) && [[ $# -eq 1 ]]; then # $MANPAGER does the trick too but lines are hard-wrapped. - nvim +"Man $* | only" + nvim +"Man $1 | only" else command man "$@" fi