From 03760e5ba16ae064d64eae4d4cde66f25ce5294a Mon Sep 17 00:00:00 2001 From: Maxime Coste Date: Thu, 6 Mar 2014 21:33:01 +0000 Subject: [PATCH] Fix man command --- rc/man.kak | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/rc/man.kak b/rc/man.kak index 401f87d8..2b913461 100644 --- a/rc/man.kak +++ b/rc/man.kak @@ -15,17 +15,21 @@ hook global WinSetOption filetype=(?!man).* %{ } def -hidden -shell-params _man %{ %sh{ - tmpfile=$(mktemp /tmp/kak-man-XXXXXX) - output=$(MANWIDTH=${kak_window_width} man "$@") - if [ $? -eq 0 ]; then - echo "${output}" | col -b > ${tmpfile} + manout=$(mktemp /tmp/kak-man-XXXXXX) + colout=$(mktemp /tmp/kak-man-XXXXXX) + MANWIDTH=${kak_window_width} man "$@" > $manout + retval=$? + col -b > ${colout} < ${manout} + rm ${manout} + if [ "${retval}" -eq 0 ]; then + echo "${output}" | echo "edit! -scratch '*man*' - exec |cat${tmpfile}gk - nop %sh{rm ${tmpfile}} + exec |cat${colout}gk + nop %sh{rm ${colout}} set buffer filetype man" else echo "echo -color Error %{man '$@' failed: see *debug* buffer for details }" - rm ${tmpfile} + rm ${colout} fi } }