From 7407fd73f024b2329ecfc827fb732207a3301e4b Mon Sep 17 00:00:00 2001 From: William Melody Date: Thu, 21 Sep 2023 21:13:46 -0700 Subject: [PATCH] Support `show --tool` option for markdown viewers. refs gh-62 --- nb | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/nb b/nb index 9105341e5..066b207c5 100755 --- a/nb +++ b/nb @@ -18827,27 +18827,30 @@ Can't show archives. Export archive and expand to edit.\\n" { cat "${_target_path}" } | { + local _markdown_tool="${_tool:-${NB_MARKDOWN_TOOL:-}}" + if _contains "${_target_extension:-}" "markdown" "md" && - _contains "${NB_MARKDOWN_TOOL:-}" \ + _command_exists "${_markdown_tool:-}" && + _contains "${_markdown_tool:-}" \ "bat" \ "glow" \ "mdcat" \ "mdless" \ "mdv" then - if [[ "${NB_MARKDOWN_TOOL:-}" == "bat" ]] + if [[ "${_markdown_tool:-}" == "bat" ]] then bat --language "${_target_extension:-md}" - elif [[ "${NB_MARKDOWN_TOOL:-}" == "glow" ]] + elif [[ "${_markdown_tool:-}" == "glow" ]] then glow --pager - elif [[ "${NB_MARKDOWN_TOOL:-}" == "mdcat" ]] + elif [[ "${_markdown_tool:-}" == "mdcat" ]] then mdcat --paginate - elif [[ "${NB_MARKDOWN_TOOL:-}" == "mdless" ]] + elif [[ "${_markdown_tool:-}" == "mdless" ]] then mdless - elif [[ "${NB_MARKDOWN_TOOL:-}" == "mdv" ]] + elif [[ "${_markdown_tool:-}" == "mdv" ]] then mdv "${_target_path}" | _pager fi