dotfiles/.config/shell/bin/upd
2022-06-22 11:12:33 -07:00

34 lines
797 B
Bash
Executable file
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#!/bin/bash
set -e
# Check for git
if ! command -v git > /dev/null; then
echo "git is not installed, please install git and try again"
exit 1
fi
# Set colors
if command -v tput > /dev/null; then
GREEN="$(tput setaf 2)"
NC="$(tput sgr0)"
elif [ -n "$TERMUX_VERSION" ]; then
GREEN=""
NC="(B"
fi
# `git pull` everything mentioned 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
if [ -n "$REPO" ]; then
if git -C "$REPO" rev-parse > /dev/null 2>&1; then
echo " ${GREEN}Pulling ${REPO/"$HOME"/"~"}${NC}"
git -C "$REPO" pull
fi
fi
done
# check for dotfiles updates
echo
echo " ${GREEN}Updating dotfiles…${NC}"
dotfiles pull