mirror of
https://github.com/ivuorinen/dotfiles.git
synced 2026-02-11 07:47:49 +00:00
chore(scripts): update cheat install scripts
This commit is contained in:
@@ -14,13 +14,19 @@ PBB_SYNTAX="syntax: bash"
|
|||||||
PBB_TAGS="tags: [bash]"
|
PBB_TAGS="tags: [bash]"
|
||||||
|
|
||||||
PBB_TEMP_PREFIX=$(basename "$0")
|
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 there's no .git, clone the folder
|
||||||
if [ ! -d "$PBB_TEMP_DIR/.git" ]; then
|
if [ ! -d "$PBB_TEMP_DIR/.git" ]; then
|
||||||
msg_run "Starting to clone $PBB_GIT"
|
msg_run "Starting to clone $PBB_GIT"
|
||||||
git clone --depth 1 --single-branch -q "$PBB_GIT" "$PBB_TEMP_DIR" \
|
git clone --depth 1 --single-branch -q "$PBB_GIT" "$PBB_TEMP_DIR" \
|
||||||
&& msg_yay "Cloned $PBB_GIT"
|
&& 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
|
fi
|
||||||
|
|
||||||
PBB_CHAPTERS=$(ls -1v "$PBB_TEMP_DIR"/manuscript/chapter*)
|
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"
|
echo -e "---\n$T---\n$(cat "$CHEAT_FILE")" > "$CHEAT_FILE"
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
# Cleanup
|
|
||||||
if [ -d "$PBB_TEMP_DIR" ]; then
|
|
||||||
rm -rf "$PBB_TEMP_DIR"
|
|
||||||
fi
|
|
||||||
|
|||||||
@@ -13,13 +13,19 @@ TLDR_SOURCE="source: $TLDR_GIT"
|
|||||||
TLDR_SYNTAX="syntax: markdown"
|
TLDR_SYNTAX="syntax: markdown"
|
||||||
|
|
||||||
TLDR_TEMP_PREFIX=$(basename "$0")
|
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 there's no .git, clone the folder
|
||||||
if [ ! -d "$TLDR_TEMP_DIR/.git" ]; then
|
if [ ! -d "$TLDR_TEMP_DIR/.git" ]; then
|
||||||
msg_run "Starting to clone $TLDR_GIT"
|
msg_run "Starting to clone $TLDR_GIT"
|
||||||
git clone --depth 1 --single-branch -q "$TLDR_GIT" "$TLDR_TEMP_DIR" \
|
git clone --depth 1 --single-branch -q "$TLDR_GIT" "$TLDR_TEMP_DIR" \
|
||||||
&& msg_done "Cloned $TLDR_GIT"
|
&& 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
|
fi
|
||||||
|
|
||||||
# Fetch the destination directory from cheat defined directories.
|
# Fetch the destination directory from cheat defined directories.
|
||||||
@@ -67,8 +73,3 @@ for d in "$TLDR_TEMP_DIR"/pages/*; do
|
|||||||
|
|
||||||
done
|
done
|
||||||
done
|
done
|
||||||
|
|
||||||
# Cleanup
|
|
||||||
if [ -d "$TLDR_TEMP_DIR" ]; then
|
|
||||||
rm -rf "$TLDR_TEMP_DIR"
|
|
||||||
fi
|
|
||||||
|
|||||||
Reference in New Issue
Block a user