1
0
Fork 0
dotfiles/.local/bin/dotsync

59 lines
1.5 KiB
Plaintext
Raw Normal View History

2023-03-28 14:24:58 +02:00
#!/bin/sh
BOLD='\033[1m'
GREEN='\033[32m'
BLUE='\033[34m'
RED='\033[31m'
NC='\033[0m'
2023-06-04 11:31:11 +02:00
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"
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
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
printf "%b" "$BOLD${BLUE}Pulling updates from dotfiles repo...$NC\n"
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
if [ $needs_pop -eq 1 ]; then
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)
if [ -n "$unmerged_files" ]; then
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-06-04 11:31:11 +02:00
printf "%s" "$unmerged_files\n"
2023-03-28 14:24:58 +02:00
else
2023-06-04 11:31:11 +02:00
stow -R -t "$HOME" dots || printf "%b" "${RED}Failed to run stow!$NC\n"
2023-03-28 14:24:58 +02:00
fi
printf "%b" "$BOLD${BLUE}Generating firefox profiles...$NC\n\n"
2023-06-04 11:31:11 +02:00
"$DOTS_DIR/.mozilla/firefox/generate.sh"
2023-03-29 00:08:17 +02:00
printf "\n"
2023-06-04 11:31:11 +02:00
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
2023-04-12 11:37:10 +02:00
if ! cd "$f"; then
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
printf "%b" "$BOLD${BLUE}Dotfiles Synced Successfully!$NC\n"