2023-12-12 17:24:59 +00:00
|
|
|
#!/usr/bin/env sh
|
|
|
|
|
|
|
|
set -e
|
|
|
|
|
|
|
|
if [ -x "$(command -v asciinema)" ] \
|
|
|
|
&& [ -z "$ASCIINEMA_REC" ] \
|
2023-12-12 17:55:53 +00:00
|
|
|
&& [ -n "$ASCIINEMA_LOG" ]
|
2023-12-12 17:24:59 +00:00
|
|
|
then
|
|
|
|
ASCIINEMA_LOG_DIR="$HOME/.cache/logs"
|
|
|
|
mkdir -p "$ASCIINEMA_LOG_DIR"
|
|
|
|
_file_name_date=$(date +%Y-%m-%d_%H%M%S)
|
|
|
|
|
2023-12-12 17:55:53 +00:00
|
|
|
if [ "$ASCIINEMA_LOG" = "raw" ]
|
|
|
|
then
|
|
|
|
export ASCIINEMA_LOG_FILE="$ASCIINEMA_LOG_DIR/asciinema-$_file_name_date.txt"
|
|
|
|
asciinema rec --quiet --raw "$ASCIINEMA_LOG_FILE"
|
|
|
|
exit 0 # Parent script should exit
|
|
|
|
fi
|
|
|
|
if [ "$ASCIINEMA_LOG" = "video" ]
|
|
|
|
then
|
|
|
|
export ASCIINEMA_LOG_FILE="$ASCIINEMA_LOG_DIR/asciinema-$_file_name_date.cast"
|
|
|
|
asciinema rec --quiet --idle-time-limit=3 "$ASCIINEMA_LOG_FILE"
|
|
|
|
exit 0 # Parent script should exit
|
|
|
|
fi
|
|
|
|
|
|
|
|
echo "Invalid value for ASCIINEMA_LOG: $ASCIINEMA_LOG"
|
|
|
|
echo "Valid values are: raw, video"
|
|
|
|
echo "Your session will not be recorded"
|
|
|
|
exit 1 # Parent script should not exit
|
2023-12-12 17:24:59 +00:00
|
|
|
fi
|
|
|
|
|
|
|
|
exit 1 # Parent script should not exit
|