Something similar is
here. Note what steeldriver says for
script
: "Note however that
script
saves everything in the terminal (rather than just command output) - including ANSI color sequences, which can make it difficult to extract plain text from the resulting file in the case of color terminals."