projects
/
libremanage.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
4f59925
)
Check in uncolor
author
Alyssa Rosenzweig
<alyssa@rosenzweig.io>
Wed, 4 Jul 2018 15:50:15 +0000
(11:50 -0400)
committer
Alyssa Rosenzweig
<alyssa@rosenzweig.io>
Wed, 4 Jul 2018 15:50:15 +0000
(11:50 -0400)
uncolor
[new file with mode: 0755]
patch
|
blob
diff --git a/uncolor
b/uncolor
new file mode 100755
(executable)
index 0000000..
96081bc
--- /dev/null
+++ b/
uncolor
@@ -0,0
+1,11
@@
+#!/usr/bin/env perl
+## uncolor ? remove terminal escape sequences such as color changes
+## Source: https://unix.stackexchange.com/questions/14684/removing-control-chars-including-console-codes-colours-from-script-output by Gilles
+while (<>) {
+ s/ \e[ #%()*+\-.\/]. |
+ \e\[ [ -?]* [@-~] | # CSI ... Cmd
+ \e\] .*? (?:\e\\|[\a\x9c]) | # OSC ... (ST|BEL)
+ \e[P^_] .*? (?:\e\\|\x9c) | # (DCS|PM|APC) ... ST
+ \e. //xg;
+ print;
+}