Skip to content

Commit

Permalink
Use kak-ansi to render man pages
Browse files Browse the repository at this point in the history
  • Loading branch information
eraserhd committed Apr 18, 2024
1 parent 42ce8d6 commit 179ecf9
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 2 deletions.
9 changes: 8 additions & 1 deletion CHANGELOG.asc
Original file line number Diff line number Diff line change
@@ -1,7 +1,14 @@
CHANGELOG
=========

== https://github.com/eraserhd/kak-ansi/compare/v0.2.6...HEAD[Unreleased]
== https://github.com/eraserhd/kak-ansi/compare/v0.2.7...HEAD[Unreleased]

== https://github.com/eraserhd/kak-ansi/compare/v0.2.6...v0.2.7[v0.2.7]

=== Added

* Override Kakoune's default `man-impl` to use `ansi-enable`. The `man`
command brought in by Nix on Mac OS has started using ANSI escapes.

== https://github.com/eraserhd/kak-ansi/compare/v0.2.5...v0.2.6[v0.2.6]

Expand Down
2 changes: 1 addition & 1 deletion derivation.nix
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

stdenv.mkDerivation rec {
name = "kak-ansi";
version = "0.2.6";
version = "0.2.7";

src = ./.;

Expand Down
29 changes: 29 additions & 0 deletions rc/ansi.kak
Original file line number Diff line number Diff line change
Expand Up @@ -76,3 +76,32 @@ define-command \
}

hook -group ansi global BufCreate '\*stdin(?:-\d+)?\*' ansi-enable

define-command -override -hidden -params ..3 man-impl %{ evaluate-commands %sh{
buffer_name="$1"
if [ -z "${buffer_name}" ]; then
exit
fi
shift
manout=$(mktemp "${TMPDIR:-/tmp}"/kak-man.XXXXXX)
manerr=$(mktemp "${TMPDIR:-/tmp}"/kak-man.XXXXXX)
env MANWIDTH=${kak_window_range##* } man "$@" > "$manout" 2> "$manerr"
retval=$?
if [ "${retval}" -eq 0 ]; then
printf %s\\n "
edit -scratch %{*$buffer_name ${*}*}
execute-keys '%|cat<space>${manout}<ret>gk'
ansi-enable
nop %sh{ rm ${manout} ${manerr} }
set-option buffer filetype man
set-option window manpage $buffer_name $*
"
else
printf '
fail %%{%s}
nop %%sh{ rm "%s" "%s" }
' "$(cat "$manerr")" "${manout}" "${manerr}"
fi
} }

0 comments on commit 179ecf9

Please sign in to comment.