Created
November 23, 2021 12:35
-
-
Save lboulard/10630da14e5d5bd8ded67e6a03a827a3 to your computer and use it in GitHub Desktop.
Cleanup typescript generated using script command
This file contains hidden or 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
#!/bin/sed -rf | |
# Requires GNU sed | |
# | |
# Based on this response: https://stackoverflow.com/a/28269556 | |
# ANSI Sequences: https://gist.github.com/fnky/458719343aabd01cfb17a3a4f7296797 | |
# Remove BEL and BACKSPACE from command line inputs | |
:again | |
s/\x07+//g | |
s/[^\x08]\x08(\x1b\[K)?// | |
t again | |
# Erase codes | |
s/(\x1b\[0?K)+/ /g | |
s/(\x1b\[0?K)+\r/\n/g | |
s/(\x1b\[1K)+/\n/g | |
# Xterm codes | |
s/\x1b_[^\x1b]*\x1b[\]//g | |
# Color codes | |
s/\x1b\[[^m]*m//g | |
# Cursor control codes | |
s/\x1b\[[^H]*H//g | |
s/\x1b\[#[A-G]//g | |
# Screen modes | |
s/\x1b\[[^h]*h//g | |
s/\x1b\[=[0-9]+l//g |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment