From 789c1039b1962008d3ddcf909a39c626b2d3eb19 Mon Sep 17 00:00:00 2001 From: PowerUser64 Date: Sun, 15 May 2022 02:05:37 -0700 Subject: [PATCH] upd: add check for if tput exists and if git repo is a repo --- .config/shell/bin/upd | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/.config/shell/bin/upd b/.config/shell/bin/upd index f9cc0cd..ebeda00 100755 --- a/.config/shell/bin/upd +++ b/.config/shell/bin/upd @@ -1,12 +1,17 @@ #!/bin/bash +if command -v tput > /dev/null; then + GREEN="$(tput setaf 2)" + NC="$(tput sgr0)" +fi + # Check for updates for thing in the REPOS_TO_UPDATE variable IFS=: read -ra REPOS_TO_UPDATE_ARR <<< "$REPOS_TO_UPDATE:$DOCS_DIR:$HOME/bin" for REPO in "${REPOS_TO_UPDATE_ARR[@]}"; do - tput setaf 2 - echo " Pulling ${REPO/$HOME/"~"}‥" - tput sgr0 - git -C "$REPO" pull + if git -C "$REPO" rev-parse > /dev/null 2>&1; then + echo " ${GREEN}Pulling ${REPO/$HOME/"~"}‥${NC}" + git -C "$REPO" pull + fi done # check for dotfiles updates