Tag Info

Hot answers tagged

16

The following script should filter out all ANSI/VT100/xterm control sequences for (based on ctlseqs). Minimally tested, please report any under- or over-match. #!/usr/bin/env perl while (<>) { s/ \e[ #%()*+\-.\/]. | (?:\e\[|\x9b) [ -?]* [@-~] | # CSI ... Cmd (?:\e\]|\x9d) .*? (?:\e\\|[\a\x9c]) | # OSC ... (ST|BEL) ...


8

Updating Gilles' answer to also remove carriage returns and do backspace-erasing of previous characters, which were both important to me for a typescript generated on Cygwin: #!/usr/bin/perl while (<>) { s/ \e[ #%()*+\-.\/]. | \r | # Remove extra carriage returns also (?:\e\[|\x9b) [ -?]* [@-~] | # CSI ... Cmd (?:\e\]|\x9d) ...


6

You can playback your typescript capture and encode the corresponding screen region using something like: ffmpeg -y -f x11grab -s 100x100 -i :0.0+100,100 -pix_fmt rgb24 -r 5 Desktop/capture.gif -y overwrites the output (most useful when testing) -f x11grab forces the format to x11grab -s 100x100 captured video is 100x100 -i :0.0+100,100 top left corner ...


5

Maybe with: if lsof -tac script "$(tty)" > /dev/null; then echo "I'm running under script" else echo "I'm not" fi You could add something like: lsof -tac script "$(tty)" > /dev/null && PS1="[script] $PS1" To your ~/.zshrc or ~/.bashrc, so the information on whether you're in script or not would be visible on your shell prompt. ...


4

Interesting problem. I found a small bash script could do the job pretty reliably: #!/bin/bash PP=$(ps -o ppid= $$) while [[ $PP != 1 ]] do LINE=$(ps -o ppid= -o comm= $PP | sed 's/^ *//') COMM=${LINE#* } PP=${LINE%% *} if [[ $COMM == script ]] # Might need a different comparison then echo "In script" exit 0 fi ...


4

I would use sed in this case. do: cat -v typescript | sed -e "s/\x1b\[.\{1,5\}m//g" sed -e "s/search/replace/g" is standard stuff. the regex is explained as below: \x1b match the Escape preceeding the color code \[ matches the first open bracket .\{1,5\} matches 1 to 5 of any single character. Have to \ the curly braces to keep the shell from mangling ...



Only top voted, non community-wiki answers of a minimum length are eligible