summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Makefile26
1 files changed, 23 insertions, 3 deletions
diff --git a/Makefile b/Makefile
index e0e9237..31c258e 100644
--- a/Makefile
+++ b/Makefile
@@ -90,9 +90,29 @@ stow: check-de
# Restow - refresh symlinks (unlink + relink)
restow: check-de
@echo "Restowing common + $(DE)..."
- @cd $(DOTFILES) && $(STOW) --restow common
- @cd $(DOTFILES) && $(STOW) --restow $(DE)
- @echo "Done."
+ @output=$$(cd $(DOTFILES) && $(STOW) -n --restow common 2>&1; cd $(DOTFILES) && $(STOW) -n --restow $(DE) 2>&1); \
+ conflicts=$$(echo "$$output" | grep "existing target" | sed 's/.*existing target //; s/ since.*//'); \
+ if [ -n "$$conflicts" ]; then \
+ echo ""; \
+ echo "Conflicts found (real files blocking symlinks):"; \
+ echo "$$conflicts" | while read -r f; do echo " ~/$$f"; done; \
+ echo ""; \
+ printf "Overwrite with repo versions? [y/N] "; \
+ read -r ans; \
+ if [ "$$ans" = "y" ] || [ "$$ans" = "Y" ]; then \
+ echo "$$conflicts" | while read -r f; do rm -f "$(HOME)/$$f"; done; \
+ cd $(DOTFILES) && $(STOW) --restow common && \
+ cd $(DOTFILES) && $(STOW) --restow $(DE); \
+ echo "Done."; \
+ else \
+ echo "Aborted. Resolve manually or use 'make reset $(DE)'."; \
+ exit 1; \
+ fi; \
+ else \
+ cd $(DOTFILES) && $(STOW) --restow common && \
+ cd $(DOTFILES) && $(STOW) --restow $(DE); \
+ echo "Done."; \
+ fi
# Reset - resolve conflicts by adopting then reverting to repo version
reset: check-de