upd: now completely updates dotfiles, also more checks and better colors
This commit is contained in:
parent
780a21b68e
commit
a0c5b3542f
1 changed files with 19 additions and 5 deletions
|
@ -1,20 +1,34 @@
|
||||||
#!/bin/bash
|
#!/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
|
if command -v tput > /dev/null; then
|
||||||
GREEN="$(tput setaf 2)"
|
GREEN="$(tput setaf 2)"
|
||||||
NC="$(tput sgr0)"
|
NC="$(tput sgr0)"
|
||||||
|
else
|
||||||
|
GREEN="\033[32m"
|
||||||
|
NC="\033[39m"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Check for updates for thing in the REPOS_TO_UPDATE variable
|
# 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"
|
IFS=: read -ra REPOS_TO_UPDATE_ARR <<< "$REPOS_TO_UPDATE:$DOCS_DIR:$HOME/bin"
|
||||||
for REPO in "${REPOS_TO_UPDATE_ARR[@]}"; do
|
for REPO in "${REPOS_TO_UPDATE_ARR[@]}"; do
|
||||||
if git -C "$REPO" rev-parse > /dev/null 2>&1; then
|
if [ -n "$REPO" ]; then
|
||||||
echo " ${GREEN}Pulling ${REPO/"$HOME"/"~"}‥${NC}"
|
if git -C "$REPO" rev-parse > /dev/null 2>&1; then
|
||||||
git -C "$REPO" pull
|
echo " ${GREEN}Pulling ${REPO/"$HOME"/"~"}‥${NC}"
|
||||||
|
git -C "$REPO" pull
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
# check for dotfiles updates
|
# check for dotfiles updates
|
||||||
echo
|
echo
|
||||||
echo " ${GREEN}Checking for dotfiles updates‥${NC}"
|
echo " ${GREEN}Updating dotfiles…${NC}"
|
||||||
dotfiles fetch
|
dotfiles pull
|
||||||
|
|
Loading…
Add table
Reference in a new issue