bash-util/scripts/record-shell

55 lines
807 B
Text
Raw Normal View History

#!/usr/bin/env bash
: '
* Record sessions with Asciinema for the Librecode project!
'
2024-10-01 13:10:07 -05:00
. "$(dirname $0)/util/logging.bash"
read -d '' usage <<EOUSAGE
2024-11-14 12:19:07 -06:00
Usage: $0 [-h|-i]
OPTIONS
-h Display this help.
2024-11-14 12:19:07 -06:00
-i Record stdin. (BE CAREFUL WITH SECRETS!)
EOUSAGE
SPOOPY_STDIN=''
while getopts 'hi' opt; do
case "${opt}" in
h)
excat "$usage"
;;
i)
SPOOPY_STDIN='--stdin'
;;
*)
dedcat "$usage"
;;
esac
done
shift $((OPTIND-1))
. /etc/os-release
timestamp=$(mktimestamp)
case "${ID}" in
arch)
SUB_ID="${BUILD_ID}"
;;
debian)
SUB_ID="${VERSION_CODENAME}"
;;
*)
SUB_ID="unknown"
;;
esac
rec_prefix="$HOME/librecode/sessions/mine/$ID/$SUB_ID"
mkdir -p "$rec_prefix"
asciinema rec $SPOOPY_STDIN "$rec_prefix/$timestamp"