Skip to content

Instantly share code, notes, and snippets.

@Khoulaiz
Created September 27, 2021 13:35
Show Gist options
  • Save Khoulaiz/cb2f58374281e0485d2445ebbc796108 to your computer and use it in GitHub Desktop.
Save Khoulaiz/cb2f58374281e0485d2445ebbc796108 to your computer and use it in GitHub Desktop.
Removes ansi stuff from a text
#!/usr/bin/env perl
## uncolor — remove terminal escape sequences such as color changes
while (<>) {
s/ \e[ #%()*+\-.\/]. |
\e\[ [ -?]* [@-~] | # CSI ... Cmd
\e\] .*? (?:\e\\|[\a\x9c]) | # OSC ... (ST|BEL)
\e[P^_] .*? (?:\e\\|\x9c) | # (DCS|PM|APC) ... ST
\e. //xg;
print;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment