2022-05-15 01:36:38 -07:00
|
|
|
|
#!/bin/bash
|
|
|
|
|
|
2022-05-22 18:57:27 -07:00
|
|
|
|
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
|
2022-05-15 02:05:37 -07:00
|
|
|
|
if command -v tput > /dev/null; then
|
|
|
|
|
GREEN="$(tput setaf 2)"
|
|
|
|
|
NC="$(tput sgr0)"
|
2022-06-22 00:36:53 -07:00
|
|
|
|
elif [ -n "$TERMUX_VERSION"]
|
|
|
|
|
GREEN="[32m"
|
|
|
|
|
NC="(B[m"
|
2022-05-15 02:05:37 -07:00
|
|
|
|
fi
|
|
|
|
|
|
2022-05-24 22:28:03 -07:00
|
|
|
|
# `git pull` everything mentioned in the REPOS_TO_UPDATE variable
|
2022-05-15 01:49:44 -07:00
|
|
|
|
IFS=: read -ra REPOS_TO_UPDATE_ARR <<< "$REPOS_TO_UPDATE:$DOCS_DIR:$HOME/bin"
|
2022-05-15 01:36:38 -07:00
|
|
|
|
for REPO in "${REPOS_TO_UPDATE_ARR[@]}"; do
|
2022-05-22 18:57:27 -07:00
|
|
|
|
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
|
2022-05-15 02:05:37 -07:00
|
|
|
|
fi
|
2022-05-15 01:36:38 -07:00
|
|
|
|
done
|
|
|
|
|
|
|
|
|
|
# check for dotfiles updates
|
|
|
|
|
echo
|
2022-05-22 18:57:27 -07:00
|
|
|
|
echo " ${GREEN}Updating dotfiles…${NC}"
|
|
|
|
|
dotfiles pull
|