chore(scripts): update cheat install scripts

This commit is contained in:
2023-10-16 10:40:56 +03:00
parent 5a95484c58
commit e42edc2dcf
2 changed files with 14 additions and 12 deletions

View File

@@ -14,13 +14,19 @@ PBB_SYNTAX="syntax: bash"
PBB_TAGS="tags: [bash]"
PBB_TEMP_PREFIX=$(basename "$0")
PBB_TEMP_DIR="/tmp/pbb-$(rnd)"
PBB_TEMP_DIR="$XDG_CACHE_HOME/cheat/pbb"
# If there's no .git, clone the folder
if [ ! -d "$PBB_TEMP_DIR/.git" ]; then
msg_run "Starting to clone $PBB_GIT"
git clone --depth 1 --single-branch -q "$PBB_GIT" "$PBB_TEMP_DIR" \
&& msg_yay "Cloned $PBB_GIT"
else
# Update the repo
msg_run "Starting to update $PBB_GIT"
git -C "$PBB_TEMP_DIR" reset --hard origin/master
git -C "$PBB_TEMP_DIR" pull -q \
&& msg_yay "Updated $PBB_GIT"
fi
PBB_CHAPTERS=$(ls -1v "$PBB_TEMP_DIR"/manuscript/chapter*)
@@ -50,8 +56,3 @@ for f in ${PBB_CHAPTERS[@]}; do
echo -e "---\n$T---\n$(cat "$CHEAT_FILE")" > "$CHEAT_FILE"
fi
done
# Cleanup
if [ -d "$PBB_TEMP_DIR" ]; then
rm -rf "$PBB_TEMP_DIR"
fi

View File

@@ -13,13 +13,19 @@ TLDR_SOURCE="source: $TLDR_GIT"
TLDR_SYNTAX="syntax: markdown"
TLDR_TEMP_PREFIX=$(basename "$0")
TLDR_TEMP_DIR="/tmp/cheat-tldr-$(rnd)"
TLDR_TEMP_DIR="$XDG_CACHE_HOME/cheat/tldr"
# If there's no .git, clone the folder
if [ ! -d "$TLDR_TEMP_DIR/.git" ]; then
msg_run "Starting to clone $TLDR_GIT"
git clone --depth 1 --single-branch -q "$TLDR_GIT" "$TLDR_TEMP_DIR" \
&& msg_done "Cloned $TLDR_GIT"
else
# Update the repo
msg_run "Starting to update $TLDR_GIT"
git -C "$TLDR_TEMP_DIR" reset --hard origin/main
git -C "$TLDR_TEMP_DIR" pull -q \
&& msg_done "Updated $TLDR_GIT"
fi
# Fetch the destination directory from cheat defined directories.
@@ -67,8 +73,3 @@ for d in "$TLDR_TEMP_DIR"/pages/*; do
done
done
# Cleanup
if [ -d "$TLDR_TEMP_DIR" ]; then
rm -rf "$TLDR_TEMP_DIR"
fi