[TriLUG] Capture Terminal Session without Control or Color Codes

Jack Hill via TriLUG trilug at trilug.org
Fri Dec 2 10:51:44 EST 2022


On Thu, 1 Dec 2022, Alan Sterger via TriLUG wrote:

> Any thing else?

Hey Alan,

I'm not sure if my recommendation will fit your requirements. Dealing with 
terminal control sequences (particularly for non-linear applications) can 
be challenging. Instead, I like the approach that asciinema [0] takes: 
record the control sequences, but also record additional metadata to 
allow playing them back. Their file-format of choice is JSON.

I've attached a small example recording. To play it back, run `asciinema 
play trilug-example`. They also have an HTML5 player. They push their 
cloud hosting service, but self-hosting is easy as well [1].

[0] https://asciinema.org/
[1] https://jackhill.us/misc/asciinema-trilug/

Best,
Jack
-------------- next part --------------
{"version": 2, "width": 132, "height": 27, "timestamp": 1669994908, "env": {"SHELL": "/gnu/store/d99ykvj3axzzidygsmdmzxah4lvxd6hw-bash-5.1.8/bin/bash", "TERM": "foot"}}
[0.013032, "o", "\u001b[?2004hjackhill at leyden ~ [env]$ "]
[3.438118, "o", "e"]
[3.63804, "o", "c"]
[3.718056, "o", "h"]
[3.814036, "o", "o"]
[3.910028, "o", " "]
[4.31009, "o", "h"]
[4.374046, "o", "e"]
[4.518066, "o", "l"]
[4.541871, "o", "e"]
[5.117912, "o", "\b\u001b[K"]
[5.358133, "o", "l"]
[6.174262, "o", "o"]
[6.902171, "o", "\r\n\u001b[?2004l\r"]
[6.902888, "o", "hello\r\n\u001b[?2004hjackhill at leyden ~ [env]$ "]
[7.990227, "o", "n"]
[8.230241, "o", "v"]
[8.302284, "o", "i"]
[8.341861, "o", "m"]
[8.46218, "o", " "]
[9.510255, "o", "f"]
[9.638233, "o", "o"]
[9.806126, "o", "o"]
[10.302141, "o", "\r\n\u001b[?2004l\r"]
[10.346181, "o", "\u001b[?1049h\u001b[22;0;0t\u001b[22;0t\u001b[?1h\u001b=\u001b[H\u001b[2J\u001b]11;?\u0007\u001b[?2004h\u001b[?u\u001b[c\u001b[?25h"]
[10.363663, "o", "\u001b[?25l\u001b[>1u\u001b(B\u001b[m\u001b[H\u001b[2J\u001b[K\n\u001b[94m~\u001b[K\r\n~\u001b[K\r\n~\u001b[K\r\n~\u001b[K\r\n~\u001b[K\r\n~\u001b[K\r\n~\u001b[K\r\n~\u001b[K\r\n~\u001b[K\r\n~\u001b[K\r\n~\u001b[K\r\n~\u001b[K\r\n~\u001b[K\r\n~\u001b[K\r\n~\u001b[K\r\n~\u001b[K\r\n~\u001b[K\r\n~\u001b[K\r\n~\u001b[K\r\n~\u001b[K\r\n~\u001b[K\r\n~\u001b[K\r\n~\u001b[K\r\n~\u001b[K\r\n\u001b(B\u001b[0;1;7mfoo                                                                                                               0,0-1          All\u001b]112\u001b\\\u001b[2 q\u001b]112\u001b\\\u001b[2 q\u001b[?1002h\u001b[?1006h\u001b[H\u001b[?25h"]
[10.44426, "o", "\u001b[?25l\u001b[?1004h\u001b[?25h"]
[10.990607, "o", "\u001b[?25l\u001b[27;122H\u001b(B\u001b[mi         \u001b[H\u001b[?25h\u001b[?25l\u001b[27;122H \u001b]112\u001b\\\u001b[6 q\u001b[H\u001b[?25h"]
[10.991352, "o", "\u001b[?25l\u001b[26B\u001b(B\u001b[0;1m-- INSERT --\u001b(B\u001b[m\u001b[K\u001b[?25h\u001b[?25l\u001b[26;117H\u001b(B\u001b[0;1;7m1  \u001b[H\u001b[?25h"]
[11.976141, "o", "\u001b[?25l\u001b(B\u001b[mh\u001b[26;5H\u001b(B\u001b[0;1;7m[+]\u001b[107C1,2\u001b[1;2H\u001b[?25h"]
[12.104045, "o", "\u001b[?25l\u001b(B\u001b[me\u001b[26;117H\u001b(B\u001b[0;1;7m3\u001b[1;3H\u001b[?25h"]
[12.19133, "o", "\u001b[?25l\u001b(B\u001b[my\u001b[26;117H\u001b(B\u001b[0;1;7m4\u001b[1;4H\u001b[?25h"]
[12.631854, "o", "\u001b[?25l\u001b[26;117H5\u001b[1;5H\u001b[?25h"]
[12.767856, "o", "\u001b[?25l\u001b(B\u001b[mt\u001b[26;117H\u001b(B\u001b[0;1;7m6\u001b[1;6H\u001b[?25h"]
[12.831641, "o", "\u001b[?25l\u001b(B\u001b[mh\u001b[26;117H\u001b(B\u001b[0;1;7m7\u001b[1;7H\u001b[?25h"]
[12.879598, "o", "\u001b[?25l\u001b(B\u001b[me\u001b[26;117H\u001b(B\u001b[0;1;7m8\u001b[1;8H\u001b[?25h"]
[12.944068, "o", "\u001b[?25l\u001b(B\u001b[mr\u001b[26;117H\u001b(B\u001b[0;1;7m9\u001b[1;9H\u001b[?25h"]
[13.040097, "o", "\u001b[?25l\u001b(B\u001b[me\u001b[26;117H\u001b(B\u001b[0;1;7m10\u001b[1;10H\u001b[?25h"]
[13.280013, "o", "\u001b[?25l\u001b(B\u001b[m\r\n\u001b[K\u001b[26;115H\u001b(B\u001b[0;1;7m2,1 \r\u001b[24A\u001b[?25h"]
[13.512033, "o", "\u001b[?25l\u001b(B\u001b[mh\u001b[26;117H\u001b(B\u001b[0;1;7m2\u001b[2;2H\u001b[?25h"]
[13.663856, "o", "\u001b[?25l\u001b(B\u001b[mo\u001b[26;117H\u001b(B\u001b[0;1;7m3\u001b[2;3H\u001b[?25h"]
[14.209015, "o", "\u001b[?25l\u001b(B\u001b[mw\u001b[26;117H\u001b(B\u001b[0;1;7m4\u001b[2;4H\u001b[?25h"]
[14.320022, "o", "\u001b[?25l\u001b(B\u001b[m'\u001b[26;117H\u001b(B\u001b[0;1;7m5\u001b[2;5H\u001b[?25h"]
[14.703819, "o", "\u001b[?25l\u001b(B\u001b[ms\u001b[26;117H\u001b(B\u001b[0;1;7m6\u001b[2;6H\u001b[?25h"]
[14.799947, "o", "\u001b[?25l\u001b[26;117H7\u001b[2;7H\u001b[?25h"]
[14.920083, "o", "\u001b[?25l\u001b(B\u001b[mi\u001b[26;117H\u001b(B\u001b[0;1;7m8\u001b[2;8H\u001b[?25h"]
[14.991897, "o", "\u001b[?25l\u001b(B\u001b[mt\u001b[26;117H\u001b(B\u001b[0;1;7m9\u001b[2;9H\u001b[?25h"]
[15.112032, "o", "\u001b[?25l\u001b[26;117H10\u001b[2;10H\u001b[?25h"]
[15.255492, "o", "\u001b[?25l\u001b(B\u001b[mg\u001b[26;118H\u001b(B\u001b[0;1;7m1\u001b[2;11H\u001b[?25h"]
[15.303641, "o", "\u001b[?25l\u001b(B\u001b[mo\u001b[26;118H\u001b(B\u001b[0;1;7m2\u001b[2;12H\u001b[?25h"]
[15.448092, "o", "\u001b[?25l\u001b(B\u001b[mi\u001b[26;118H\u001b(B\u001b[0;1;7m3\u001b[2;13H\u001b[?25h"]
[15.487801, "o", "\u001b[?25l\u001b(B\u001b[mn\u001b[26;118H\u001b(B\u001b[0;1;7m4\u001b[2;14H\u001b[?25h"]
[15.567783, "o", "\u001b[?25l\u001b(B\u001b[mg\u001b[26;118H\u001b(B\u001b[0;1;7m5\u001b[2;15H\u001b[?25h"]
[15.904325, "o", "\u001b[?25l\u001b(B\u001b[me\u001b[26;118H\u001b(B\u001b[0;1;7m6\u001b[2;16H\u001b[?25h"]
[16.751094, "o", "\u001b[?25l\u001b(B\u001b[m\b \u001b[26;118H\u001b(B\u001b[0;1;7m5\u001b[2;15H\u001b[?25h"]
[18.350569, "o", "\u001b[?25l\u001b(B\u001b[m\r\u001b[25B\u001b[12X\u001b]112\u001b\\\u001b[2 q\u001b[2;15H\u001b[?25h"]
[18.351424, "o", "\u001b[?25l\u001b[26;118H\u001b(B\u001b[0;1;7m4\u001b[2;14H\u001b[?25h"]
[19.286795, "o", "\u001b[?25l\u001b[27;122H\u001b(B\u001b[m:\u001b[2;14H\u001b[?25h\u001b[?25l\u001b[27;122H \r\u001b[27;1H:\u001b]112\u001b\\\u001b[2 q\u001b[?1002l\u001b[?1006l\u001b[?25h"]
[19.566674, "o", "\u001b[?25lw\u001b[?25h"]
[19.734433, "o", "\u001b[?25lq\u001b[?25h"]
[20.318614, "o", "\u001b[?25l\r\u001b[27;1H\u001b[?25h"]
[20.319323, "o", "\u001b[?25l\"foo\"\u001b]112\u001b\\\u001b[2 q\u001b[?1002h\u001b[?1006h\u001b[?25h"]
[20.324519, "o", "\u001b[?25l\u001b[C[New] 2L, 25B written\r\u001b[27;1H\u001b[?25h\u001b[?25l\u001b]112\u001b\\\u001b[2 q\u001b[?1002l\u001b[?1006l\u001b(B\u001b[m\u001b[?25h\u001b[?1l\u001b>\u001b[<1u\u001b[?1049l\u001b[23;0;0t\u001b[23;0t\u001b[?2004l\u001b[?1004l\u001b[?25h"]
[20.33086, "o", "\u001b[?2004hjackhill at leyden ~ [env]$ "]
[21.326483, "o", "e"]
[21.542599, "o", "x"]
[21.654436, "o", "i"]
[21.766388, "o", "t"]
[22.110448, "o", "\r\n\u001b[?2004l\r"]
[22.111125, "o", "exit\r\n"]


More information about the TriLUG mailing list