forked from johnandersen777/dotfiles
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.asciinema_source
25 lines (21 loc) · 943 Bytes
/
.asciinema_source
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
#!/usr/bin/env bash
export REC_HOSTNAME="${REC_HOSTNAME:-$(hostname)}"
if [[ "x${TMUX}" == "x" ]]; then
# TODO fix case where exit 0 but no sessions
tmux ls 1>/dev/null 2>&1
exit_code=$?
if [[ ! -d "$HOME/asciinema/" ]]; then
mkdir -p "$HOME/asciinema/"
fi
outfile="$HOME/asciinema/rec-$(hostname)-$(date +%4Y-%m-%d-%H-%M-%ss).ndjson"
# >(xz --stdout - > "$HOME/asciinema/rec-$(hostname)-$(date +%4Y-%m-%d-%H-%M-%ss).ndjson.xz")
if [[ "x${exit_code}" == "x0" ]]; then
$PYTHON -m asciinema rec --idle-time-limit 0.5 --title "$(date +%4Y-%m-%d-%H-%M-%ss)${TITLE}" --command "${ASCIINEMA_SSH} tmux a" "${outfile}"
else
$PYTHON -m asciinema rec --idle-time-limit 0.5 --title "$(date +%4Y-%m-%d-%H-%M-%ss)${TITLE}" --command "${ASCIINEMA_SSH} tmux" "${outfile}"
fi
fi
asciinema-upload-last() {
rec_file=$(ls ${HOME}/asciinema/rec-$(hostname)-*.ndjson | tail -n 1)
$PYTHON -m asciinema upload "${rec_file}"
}