From 3f621617efc8bb730b2b05082cecaeaf15eddd6c Mon Sep 17 00:00:00 2001 From: Julian Prein Date: Fri, 20 Jun 2025 15:41:35 +0200 Subject: [PATCH] less: Open file (also stdin) in vim with e/E The current file can be edited with `v` already, but this doesn't work when reading from stdin. --- .config/lesskey | 11 +++++++++++ .local/bin/no-ansi-sgr | 8 ++++++++ 2 files changed, 19 insertions(+) create mode 100755 .local/bin/no-ansi-sgr diff --git a/.config/lesskey b/.config/lesskey index a1859b6..0b460d7 100644 --- a/.config/lesskey +++ b/.config/lesskey @@ -1,6 +1,17 @@ # SPDX-License-Identifier: MIT # Copyright (c) 2025 Julian Prein +#command + +# NOTE: the current file can be edited with `v` already, but this doesn't work +# when reading from stdin +# NOTE: ^P omits the "done" message +# +# edit in vim without any ANSI SGR sequences (e.g. color) +e noaction g|$no-ansi-sgr | nvim -\n +# edit in vim while keeping them +E noaction g|$nvim -\n + #env # NOTE: Lines need a trailing space when concatenating diff --git a/.local/bin/no-ansi-sgr b/.local/bin/no-ansi-sgr new file mode 100755 index 0000000..acc41aa --- /dev/null +++ b/.local/bin/no-ansi-sgr @@ -0,0 +1,8 @@ +#!/bin/sed -f +# SPDX-License-Identifier: MIT +# Copyright (c) 2025 Julian Prein +# +# Remove ANSI SGR (Select Graphic Rendition) escape sequences, e.g. setting +# color or bold font. + +s/\[[^m]*m//g