Files
dotfiles/.local/bin/no-ansi-sgr
Julian Prein 75fb2f56a2 bin:no-ansi-sgr: Conform to specification
Previously - in the existence of other ANSI escape sequences - the
script deleted text due to the too broad regex. For example in:

    foo^[[K bar m

everything behind `foo` was deleted. Thus, only remove SGR sequences by
only matching the spec-allowed bytes.
2025-08-04 11:00:00 +02:00

10 lines
247 B
Sed
Executable File
Raw Blame History

This file contains invisible Unicode characters
This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
#!/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.
# TODO: Why is the range `[0-?]` invalid?
s/\[[0-9:-?]*[ -/]*m//g