-
Notifications
You must be signed in to change notification settings - Fork 343
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
demos: run scripts in a fixed environment and record with term-transc…
…ript
- Loading branch information
Showing
2 changed files
with
56 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -39,3 +39,27 @@ comment() { | |
echo -e "\033[0;32m${indented}\033[0m" | ||
blank | ||
} | ||
|
||
git_config() { | ||
cat <<'EOF' > "$1" | ||
[color] | ||
ui=always | ||
EOF | ||
} | ||
|
||
jj_config() { | ||
cat <<'EOF' > "$1" | ||
[user] | ||
name = "JJ Fan" | ||
email = "[email protected]" | ||
[operation] | ||
hostname = "jujube" | ||
username = "jjfan" | ||
[ui] | ||
color="always" | ||
paginate="never" | ||
log-word-wrap=true # Need to set COLUMNS for this to work | ||
EOF | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
#!/bin/bash | ||
set -euo pipefail | ||
. "$(dirname "$0")"/helpers.sh | ||
|
||
which term-transcript > /dev/null || echo "\`term-transcipt\` must be installed with e.g. \`cargo binstall term-transcript-cli\`. See also https://github.com/slowli/term-transcript" | ||
which convert > /dev/null || echo "\`convert\` from ImageMagik needs to be installed to create pngs. Only svgs will be created." >&2 | ||
|
||
echo "jj --version: (set PATH to change)" | ||
jj --version | ||
|
||
JJ_CONFIG=$(mktemp --tmpdir jjconfig-XXXX.toml) | ||
export JJ_CONFIG | ||
jj_config "$JJ_CONFIG" | ||
|
||
GIT_CONFIG_GLOBAL=$(mktemp --tmpdir gitconfig-XXXX) | ||
export GIT_CONFIG_GLOBAL | ||
git_config "$GIT_CONFIG_GLOBAL" | ||
|
||
# Make `jj` wrap text as opposed to `term-transcript` | ||
# Currently, 80 is the only value the tool supports when | ||
# used as a CLI. | ||
# https://github.com/slowli/term-transcript/issues/59 | ||
COLUMNS=80 | ||
export COLUMNS | ||
|
||
for script in "$@"; do | ||
script_base="${script%.sh}" | ||
script_base="${script_base#demo_}" | ||
(bash "$script" || echo 'SCRIPT FAIL') 2>&1 | tee /dev/stderr | term-transcript capture --no-inputs --pure-svg --out "$script_base".svg "$script_base" | ||
# Resize to 700 width and any height | ||
which convert > /dev/null && convert -resize 700x10000 -colors 50 -background black "$script_base".svg "$script_base".png || true | ||
done |