From 864fbc18dae6770e005dcea406c9d9d97993d4d1 Mon Sep 17 00:00:00 2001 From: Ismo Vuorinen Date: Mon, 8 May 2023 12:18:10 +0300 Subject: [PATCH] feat(dfm): Install cheat databases with dfm --- local/bin/dfm | 8 ++++++++ scripts/install-cheat-purebashbible.sh | 7 ++++--- scripts/install-cheat-tldr.sh | 6 ++++-- 3 files changed, 16 insertions(+), 5 deletions(-) diff --git a/local/bin/dfm b/local/bin/dfm index 9db0da0..0d9c2e5 100755 --- a/local/bin/dfm +++ b/local/bin/dfm @@ -28,6 +28,7 @@ function section_install MENU=( "all:Installs everything in the correct order" "antigen:Updates the antigen.zsh file" + "cheat-databases:Install cheat external cheatsheet databases" "composer:Install composer" "dotenv:Install dotenv-linter" "gh:Install GitHub CLI Extensions" @@ -53,6 +54,7 @@ function section_install $0 install fzf $0 install gh $0 install go + $0 install cheat-databases $0 install imagick $0 install neofetch $0 install nvm @@ -64,6 +66,12 @@ function section_install curl -sSfL git.io/antigen -o "$DOTFILES/local/bin/antigen.zsh" \ && msg_yay "New antigen installed!" ;; + cheat-databases) + for database in "$DOTFILES"/scripts/install-cheat-*; do + bash "$database" \ + && msg_yay "Cheat: $database run" + done + ;; composer) bash "$DOTFILES/scripts/install-composer.sh" \ && msg_yay "composer installed!" diff --git a/scripts/install-cheat-purebashbible.sh b/scripts/install-cheat-purebashbible.sh index 3629dfa..5c1d7df 100755 --- a/scripts/install-cheat-purebashbible.sh +++ b/scripts/install-cheat-purebashbible.sh @@ -18,7 +18,9 @@ PBB_TEMP_DIR="/tmp/pbb-$(rnd)" # If there's no .git, clone the folder if [ ! -d "$PBB_TEMP_DIR/.git" ]; then - git clone "$PBB_GIT" "$PBB_TEMP_DIR" + msg_run "Starting to clone $PBB_GIT" + git clone --depth 1 --single-branch -q "$PBB_GIT" "$PBB_TEMP_DIR" \ + && msg_yay "Cloned $PBB_GIT" fi PBB_CHAPTERS=$(ls -1v "$PBB_TEMP_DIR"/manuscript/chapter*) @@ -32,10 +34,9 @@ for f in ${PBB_CHAPTERS[@]}; do # get all headers, take the first one, strip the # and return the first word in lowercase HEADER=$(grep -e '^[#] ' "$f" | head -1 | awk '{print tolower($2)}') CHEAT_FILE="$CHEAT_DEST/${HEADER}" - echo "(*) $CHEAT_FILE" if [ ! -f "$CHEAT_FILE" ]; then - cp "$f" "$CHEAT_FILE" + cp "$f" "$CHEAT_FILE" && msg_run "$CHEAT_FILE" fi LC_ALL=C perl -pi.bak -e 's/\<\!-- CHAPTER END --\>//' "$CHEAT_FILE" diff --git a/scripts/install-cheat-tldr.sh b/scripts/install-cheat-tldr.sh index 1b9753a..c02d2f4 100755 --- a/scripts/install-cheat-tldr.sh +++ b/scripts/install-cheat-tldr.sh @@ -17,7 +17,9 @@ TLDR_TEMP_DIR="/tmp/cheat-tldr-$(rnd)" # If there's no .git, clone the folder if [ ! -d "$TLDR_TEMP_DIR/.git" ]; then - git clone --depth 1 "$TLDR_GIT" "$TLDR_TEMP_DIR" + msg_run "Starting to clone $TLDR_GIT" + git clone --depth 1 --single-branch -q "$TLDR_GIT" "$TLDR_TEMP_DIR" \ + && msg_done "Cloned $TLDR_GIT" fi # Fetch the destination directory from cheat defined directories. @@ -50,7 +52,7 @@ for d in "$TLDR_TEMP_DIR"/pages/*; do # echo "-> dest: $TLDR_FILE" if [ ! -f "$TLDR_FILE" ]; then - cp "$FILE" "$TLDR_FILE" + cp "$FILE" "$TLDR_FILE" && msg_run "$TLDR_FILE" fi if [ -f "$TLDR_FILE" ] && [ '---' != "$(head -1 < "$TLDR_FILE")" ]; then