59 lines
1.5 KiB
Bash
Executable File
59 lines
1.5 KiB
Bash
Executable File
#!/bin/sh
|
|
|
|
BOLD='\033[1m'
|
|
GREEN='\033[32m'
|
|
BLUE='\033[34m'
|
|
RED='\033[31m'
|
|
NC='\033[0m'
|
|
|
|
printf "%b" "$BOLD${BLUE}Changing directory to $DOTS_DIR$NC\n"
|
|
if ! cd "$DOTS_DIR"; then
|
|
printf "%b" "${RED}Could not CD into $DOTS_DIR$NC\n"
|
|
exit
|
|
fi
|
|
printf "\n"
|
|
|
|
printf "%b" "$BOLD${BLUE}Stashing existing changes...$NC\n"
|
|
stash_result=$(git stash push -m "sync-dotfiles: Before syncing dotfiles")
|
|
needs_pop=1
|
|
if [ "$stash_result" = "No local changes to save" ]; then
|
|
needs_pop=0
|
|
fi
|
|
printf "\n"
|
|
|
|
printf "%b" "$BOLD${BLUE}Pulling updates from dotfiles repo...$NC\n"
|
|
git pull origin main --recurse-submodules=yes
|
|
printf "\n"
|
|
|
|
if [ $needs_pop -eq 1 ]; then
|
|
printf "%b" "$BOLD${BLUE}Popping stashed changes...$NC\n"
|
|
git stash pop
|
|
fi
|
|
printf "\n"
|
|
|
|
unmerged_files=$(git diff --name-only --diff-filter=U)
|
|
if [ -n "$unmerged_files" ]; then
|
|
printf "%b" "${RED}The following files have merge conflicts after popping the stash:$NC\n"
|
|
printf "\n"
|
|
printf "%s" "$unmerged_files\n"
|
|
else
|
|
stow -R -t "$HOME" dots || printf "%b" "${RED}Failed to run stow!$NC\n"
|
|
fi
|
|
|
|
printf "%b" "$BOLD${BLUE}Generating firefox profiles...$NC\n\n"
|
|
"$DOTS_DIR/.mozilla/firefox/generate.sh"
|
|
printf "\n"
|
|
|
|
printf "%b" "${BOLD}Recompile/Install src files? ${GREEN}Y/N?$NC\n"
|
|
read -r ans
|
|
[ "$ans" = "y" ] && for f in "$DOTS_DIR"/.local/src/*; do
|
|
if ! cd "$f"; then
|
|
printf "%b" "${RED}Could not CD into $f$NC\n"
|
|
exit
|
|
fi
|
|
sudo make install
|
|
make clean
|
|
done
|
|
|
|
printf "%b" "$BOLD${BLUE}Dotfiles Synced Successfully!$NC\n"
|