-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
record terminal traffic and use as contest
- Loading branch information
1 parent
e38cc42
commit 279f152
Showing
2 changed files
with
34 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
#!/usr/bin/perl | ||
|
||
# https://unix.stackexchange.com/questions/14684/removing-control-chars-including-console-codes-colours-from-script-output licensed under CC BY-SA 4.0 | ||
# GNU sed and POSIX bash does not support PCRE features like look-ahead. Therefore, adding new a dependency is not avoidable. | ||
|
||
while (<>) { | ||
s/ \e[ #%()*+\-.\/]. | | ||
\r | # Remove extra carriage returns also | ||
(?:\e\[|\x9b) [ -?]* [@-~] | # CSI ... Cmd | ||
(?:\e\]|\x9d) .*? (?:\e\\|[\a\x9c]) | # OSC ... (ST|BEL) | ||
(?:\e[P^_]|[\x90\x9e\x9f]) .*? (?:\e\\|\x9c) | # (DCS|PM|APC) ... ST | ||
\e.|[\x80-\x9f] //xg; | ||
1 while s/[^\b][\b]//g; | ||
print; | ||
} |