1 `script` is a nice utility for recording terminal sessions. It spawns
2 a new shell (by default), and records any activity in that shell:
5 Script started, file is /tmp/script
6 $ ps -u wking | grep script
7 12102 pts/7 00:00:00 script
8 12103 pts/7 00:00:00 script
10 script───script───bash───pstree
13 Script done, file is /tmp/script
15 The recorded file stores all the characters sent to the terminal:
18 Script started on Mon 10 Dec 2012 08:07:17 AM EST
19 ^[]0;wking@mjolnir:~^G^[[?1034h^[[01;32mwking@mjolnir^[[01;34m ~ $^[[00m ps -u wking | grep script^M
20 12102 pts/7 00:00:00 ^[[01;31m^[[Kscript^[[m^[[K^M
21 12103 pts/7 00:00:00 ^[[01;31m^[[Kscript^[[m^[[K^M
22 ^[]0;wking@mjolnir:~^G^[[01;32mwking@mjolnir^[[01;34m ~ $^[[00m pstr^G^M
24 ^[[01;32mwking@mjolnir^[[01;34m ~ $^[[00m pstr^M
26 ^[[01;32mwking@mjolnir^[[01;34m ~ $^[[00m pstree 12102^M
27 scriptM-bM-^TM-^@M-bM-^TM-^@M-bM-^TM-^@scriptM-bM-^TM-^@M-bM-^TM-^@M-bM-^TM-^@bashM-bM-^TM-^@M-bM-^TM-^@M-bM-^TM-^@pstree^M
28 ^[]0;wking@mjolnir:~^G^[[01;32mwking@mjolnir^[[01;34m ~ $^[[00m exit^M
31 Script done on Mon 10 Dec 2012 08:07:51 AM EST
33 You can also record timing information in a separate file (this
34 approach was developed by Joey Hess and posted in [Debian bug
37 $ script --timing=/tmp/timing /tmp/script
38 Script started, file is /tmp/script
43 Script done, file is /tmp/script
45 The timing file has a “delay in seconds” column and a “number of
46 characters to send column”:
54 You can play back a script with timing information:
56 $ scriptreplay -t /tmp/timing -s /tmp/script
59 You can also play it back with altered timing (e.g. in slow motion):
61 $ scriptreplay -t /tmp/timing -s /tmp/script -d 0.5
62 …half-speed playback playback…
64 This even works reasonably well with curses applications (`emacs`,
65 `vi`, …), but information such as window size is not recorded or
66 replayed. From util-linux's `scriptreplay(1)`:
68 > Since the same information is simply being displayed, scriptreplay
69 > is only guaranteed to work properly if run on the same type of
70 > terminal the typescript was recorded on. Otherwise, any escape
71 > characters in the typescript may be interpreted differently by the
72 > terminal to which scriptreplay is sending its output.
74 This means that if you want interoperable replay, you'll want to do
78 $ echo "$TERM $LINES $COLUMNS"
81 early on so folks know how to setup their replay environment. If
82 you're using some wonky `$TERM`, you may even want to post your
86 xterm|xterm terminal emulator (X Window System),
87 am, bce, km, mc5i, mir, msgr, npc, xenl,
88 colors#8, cols#80, it#8, lines#24, pairs#64,
89 acsc=``aaffggiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz{{||}}~~,
92 The user can compare with their current terminal:
95 comparing xterm to linux.
106 It would be nice if there was an `iconv`-style converter to translate
107 between terminal operation encodings, but I haven't found one yet.
108 [[Screen]] [does something like this internally][screen], and their
109 [list of control sequences][seq] is a useful reference. I've started
110 work on an [[escape-sequence-to-HTML
111 converter|script/script-publish.py]], in case you want to play around
112 with these conversions in [[Python]].
115 [68556]: http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=68556
116 [screen]: http://www.gnu.org/software/screen/manual/html_node/Virtual-Terminal.html
117 [seq]: http://www.gnu.org/software/screen/manual/html_node/Control-Sequences.html#Control-Sequences