From 3dbffbc08ea6653879b96b0dd68a50931cac09f5 Mon Sep 17 00:00:00 2001 From: Julian Prein Date: Thu, 3 Feb 2022 16:39:39 +0100 Subject: [PATCH] zsh:funcs:nvim-man: Check if `stdout` is terminal If `stdout` is not a terminal, `command man` should be used as `nvim` won't work. --- .config/zsh/zshrc.d/40-functions.zsh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.config/zsh/zshrc.d/40-functions.zsh b/.config/zsh/zshrc.d/40-functions.zsh index 01b8299..4410506 100644 --- a/.config/zsh/zshrc.d/40-functions.zsh +++ b/.config/zsh/zshrc.d/40-functions.zsh @@ -397,9 +397,9 @@ git-commit-last-msg() { } nvim-man() { - # Use nvim only if it exists, there was just one argument passed and that - # argument is not an option (e.g. `--version`) - if (( $+commands[nvim] && $# == 1 && $1 == ${1#-} )); then + # Use nvim only if it exists, there was just one argument passed, that + # argument is not an option (e.g. `--version`) and stdout is a terminal. + if (( $+commands[nvim] && $# == 1 && $1 == ${1#-} )) && [[ -t 1 ]]; then # Check for existence of man page. command man -w "$1" >/dev/null || return