From cf17522d5032852c8defa5a57fa439598c932380 Mon Sep 17 00:00:00 2001 From: Mariell Hoversholm Date: Sun, 6 Aug 2023 20:20:06 +0200 Subject: [PATCH] perf: use sed for colour removals This has a notable change of performance. --- neofetch | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/neofetch b/neofetch index 0e3c411b..97498f93 100755 --- a/neofetch +++ b/neofetch @@ -5152,7 +5152,7 @@ print_ascii() { strip_escape_codes "${line}" line # Use patterns to replace color codes that the above line did not catch line=${line//\\033\[*([0-9;])[JKmsu]/} - line=${line//\[*([0-9;])[JKmsu]/} + line="$(printf %b "$line" | sed -E 's/'"$(printf %b '\x1B')"'\[*[0-9;]+[JKmsu]//g')" ((++lines,${#line}>ascii_len)) && ascii_len="${#line}" done <<< "${ascii_data//\$\{??\}}" fi