I am trying to setup my environment so that all opened terminal sessions are automatically recorded by asciinema, to be able to easily replay anything from my history.
I use zsh
shell and I run this in .zshrc
:
if [ "$ASCIINEMA_REC" != "1" ]; then
local out="rec.json"
local loc="$HOME/.asciinema"
if [ -d "${loc}" ]; then
out="${loc}`pwd`/rec_`date +'%Y-%b-%d_%H-%M-%S'`_pts-`basename $TTY`.json"
mkdir -p "`dirname ${out}`"
fi
asciinema rec -q -w 1 ${out};
fi
However the problem is when I close the terminal window (using X). The output is not properly closed and ends up being empty. Also the initialization takes longer now since it is initializing zsh shell two times.