Add terminal log using asciinema

This commit is contained in:
Tobias Reisinger 2023-12-12 18:24:59 +01:00
parent 6f6ca6f79d
commit 41935c352c
Signed by: serguzim
GPG key ID: 13AD60C237A28DFE
5 changed files with 23 additions and 0 deletions

18
.bin/asciinema-log Executable file
View file

@ -0,0 +1,18 @@
#!/usr/bin/env sh
set -e
if [ -x "$(command -v asciinema)" ] \
&& [ -z "$ASCIINEMA_REC" ] \
&& [ "$ASCIINEMA_LOG" -gt 0 ]
then
ASCIINEMA_LOG_DIR="$HOME/.cache/logs"
mkdir -p "$ASCIINEMA_LOG_DIR"
_file_name_date=$(date +%Y-%m-%d_%H%M%S)
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
exit 1 # Parent script should not exit

View file

@ -7,6 +7,7 @@ alias aliases='$EDITOR ~/.config/aliasrc && . ~/.config/aliasrc'
alias aliases.local='$EDITOR ~/.config/aliasrc.local && . ~/.config/aliasrc'
# shellcheck disable=2154
alias arch-deps2deps='set -a; source PKGBUILD; set +a; paru -S --asdeps --noconfirm $depends && paru -Ui --rebuild'
alias asciinema-clear-log='if [ -f "$ASCIINEMA_LOG_FILE" ]; then \rm -v "$ASCIINEMA_LOG_FILE"; else echo "No log file found"; fi'
alias bspwm-default='echo "default" > /tmp/bspwm_mode; bspc wm -r'
alias bspwm-present='echo "presenter" > /tmp/bspwm_mode; bspc wm -r'

View file

@ -1,6 +1,7 @@
#!/bin/sh
export AUTOSTART_DISPLAY="Hyprland"
export ASCIINEMA_LOG="1"
export MONITOR_PRIMARY="DisplayPort-0"
export MONITOR_SECONDARY="HDMI-A-0"

View file

@ -3,6 +3,7 @@
{
# Packages that should be installed to the user profile.
home.packages = with pkgs; [
asciinema # tool to record terminal sessions
bat # cat-alternative
direnv # tool to load custom environments
docker-credential-helpers

View file

@ -122,3 +122,5 @@ source source-remote-file \
[ -x "$(command -v direnv)" ] && eval "$(direnv hook zsh)"
[ -x "$(command -v starship)" ] && eval "$(starship init zsh)"
asciinema-log && exit