1
1
mirror of https://github.com/mawww/kakoune.git synced 2024-09-19 08:47:46 +03:00

Fix man command

This commit is contained in:
Maxime Coste 2014-03-06 21:33:01 +00:00
parent f733007a7b
commit 03760e5ba1

View File

@ -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<space>${tmpfile}<ret>gk
nop %sh{rm ${tmpfile}}
exec |cat<space>${colout}<ret>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
} }