2023-03-28 14:24:58 +02:00
|
|
|
#!/bin/sh
|
|
|
|
|
2023-05-29 22:20:46 +02:00
|
|
|
BOLD='\033[1m'
|
|
|
|
GREEN='\033[32m'
|
|
|
|
BLUE='\033[34m'
|
|
|
|
RED='\033[31m'
|
|
|
|
NC='\033[0m'
|
|
|
|
|
2023-05-31 09:41:28 +02:00
|
|
|
printf "%b" "$BOLD${BLUE}Changing directory to $DOTFILES_DIR$NC\n"
|
|
|
|
if ! cd "$DOTFILES_DIR"; then
|
|
|
|
printf "%b" "${RED}Could not CD into $DOTFILES_DIR$NC\n"
|
2023-04-12 11:37:10 +02:00
|
|
|
exit
|
2023-03-28 19:13:13 +02:00
|
|
|
fi
|
2023-03-29 00:08:17 +02:00
|
|
|
printf "\n"
|
2023-03-28 14:24:58 +02:00
|
|
|
|
2023-05-29 22:20:46 +02:00
|
|
|
printf "%b" "$BOLD${BLUE}Stashing existing changes...$NC\n"
|
2023-03-28 14:24:58 +02:00
|
|
|
stash_result=$(git stash push -m "sync-dotfiles: Before syncing dotfiles")
|
|
|
|
needs_pop=1
|
|
|
|
if [ "$stash_result" = "No local changes to save" ]; then
|
2023-04-12 11:37:10 +02:00
|
|
|
needs_pop=0
|
2023-03-28 14:24:58 +02:00
|
|
|
fi
|
2023-03-29 00:08:17 +02:00
|
|
|
printf "\n"
|
2023-03-28 14:24:58 +02:00
|
|
|
|
2023-05-29 22:20:46 +02:00
|
|
|
printf "%b" "$BOLD${BLUE}Pulling updates from dotfiles repo...$NC\n"
|
2023-05-31 11:27:31 +02:00
|
|
|
git pull origin main --recurse-submodules=yes
|
2023-03-29 00:08:17 +02:00
|
|
|
printf "\n"
|
2023-03-28 14:24:58 +02:00
|
|
|
|
2023-03-28 14:31:21 +02:00
|
|
|
if [ $needs_pop -eq 1 ]; then
|
2023-05-29 22:20:46 +02:00
|
|
|
printf "%b" "$BOLD${BLUE}Popping stashed changes...$NC\n"
|
2023-04-12 11:37:10 +02:00
|
|
|
git stash pop
|
2023-03-28 14:24:58 +02:00
|
|
|
fi
|
2023-03-29 00:08:17 +02:00
|
|
|
printf "\n"
|
2023-03-28 14:24:58 +02:00
|
|
|
|
|
|
|
unmerged_files=$(git diff --name-only --diff-filter=U)
|
2023-03-28 14:31:21 +02:00
|
|
|
if [ -n "$unmerged_files" ]; then
|
2023-05-29 22:20:46 +02:00
|
|
|
printf "%b" "${RED}The following files have merge conflicts after popping the stash:$NC\n"
|
2023-04-12 11:37:10 +02:00
|
|
|
printf "\n"
|
2023-05-29 22:20:46 +02:00
|
|
|
printf "$unmerged_files\n"
|
2023-03-28 14:24:58 +02:00
|
|
|
else
|
2023-05-29 22:20:46 +02:00
|
|
|
stow --dotfiles -t "$HOME" . || printf "%b" "${RED}Failed to run stow!$NC\n"
|
2023-03-28 14:24:58 +02:00
|
|
|
fi
|
|
|
|
|
2023-05-29 22:20:46 +02:00
|
|
|
printf "%b" "$BOLD${BLUE}Generating firefox profiles...$NC\n\n"
|
2023-05-31 09:41:28 +02:00
|
|
|
"$DOTFILES_DIR/.mozilla/firefox/generate.sh"
|
2023-03-29 00:08:17 +02:00
|
|
|
printf "\n"
|
|
|
|
|
2023-05-29 22:20:46 +02:00
|
|
|
printf "${BOLD}Recompile/Install src files? ${GREEN}Y/N?$NC\n"
|
|
|
|
read ans
|
2023-05-31 09:41:28 +02:00
|
|
|
[ "$ans" = "y" ] && for f in "$DOTFILES_DIR"/.local/src/*; do
|
2023-04-12 11:37:10 +02:00
|
|
|
if ! cd "$f"; then
|
2023-05-29 22:20:46 +02:00
|
|
|
printf "%b" "${RED}Could not CD into $f$NC\n"
|
2023-04-12 11:37:10 +02:00
|
|
|
exit
|
|
|
|
fi
|
|
|
|
sudo make install
|
2023-03-29 00:09:07 +02:00
|
|
|
make clean
|
2023-03-29 00:08:17 +02:00
|
|
|
done
|
|
|
|
|
2023-05-29 22:20:46 +02:00
|
|
|
printf "%b" "$BOLD${BLUE}Dotfiles Synced Successfully!$NC\n"
|