Saturday, January 17, 2009

Console screencast

Recording your work sessions in terminal is easy. The tool by the name of "script" that is included into util-linux-ng package can track all your actions, write them into a file and playback later. More specifically, the program records your input and terminal's output. The most interesting part is replaying these logs in realtime. That can be performed with the help of "typescript" tool (written in Perl).

> script -t 2>replayfile
> # perform actions..
> Ctrl^D
> scriptreplay ./replayfile

Option -t means the timeline will be written to stderr. By default, scriptreplay reads "typescript" file and playbacks it at the normal speed. You can change it by pointing another file or setting another playback speed:

> script -t 2>replayfile my_typescript
> scriptreplay ./replayfile ./my_typescript 3

Here "3" means the actions will be played 3 times faster.

Another interesting use is recording working sessions with pseudographic applications. It can be useful if you perform some risky actions (for example, disk partitioning with cfdisk) and you need to blamestorm later or to give a master class. Creating tutorials - one more way to prove your virtuosity in using vim.