Record terminal session in a tmux friendly way.

Use script from bsdutils package to record terminal using session name</strong>-pane name-date naming scheme.


typescript_log_type="io" # "io" (in/out) or "out" (only out)
typescript_name="$(tmux display-message -p ';#S-#P';)-$(date +%Y%m%d_%H%M)"

if [ ! -d "$typescript_directory" ]; then
  mkdir $typescript_directory

script --append \
       --log-timing \
         "${typescript_directory}/${typescript_name}.timing" \
       --log-${typescript_log_type} \
         "${typescript_directory}/${typescript_name}.${typescript_log_type}" \
       --logging-format advanced 

Execute terminal recording.

$ record           
Script started, output log file is '/home/milosz/.typescript/', input log file is '/home/milosz/.typescript/', timing file is '/home/milosz/.typescript/milosz-1-20210718_2344.timing'.

$ ....

Script done.

Inspect created files.

❯ ls ~/.typescript/  milosz-1-20210718_2344.timing

Replay terminal recording.

$ scriptreplay --log-timing ~/.typescript/milosz-1-20210718_2344.timing --log-io ~/.typescript/ 

This simple shell script is very useful at times when I need need to record a particular operation inside terminal.