diff options
| -rw-r--r-- | Makefile | 46 |
1 files changed, 39 insertions, 7 deletions
@@ -7,7 +7,7 @@ DOTFILES := $(shell pwd)/dotfiles # Extract DE from command line (e.g., 'make stow dwm' -> DE=dwm) DE := $(filter dwm hyprland,$(MAKECMDGOALS)) -.PHONY: help stow restow adopt unstow dwm hyprland +.PHONY: help stow restow reset unstow import dwm hyprland # Default target - show help help: @@ -22,14 +22,16 @@ help: @echo "Targets:" @echo " stow Create symlinks (fresh install)" @echo " restow Refresh symlinks (unlink + relink)" - @echo " adopt Pull system files into repo, then reset to repo version" + @echo " reset Resolve conflicts, keep repo version (adopt + git checkout)" @echo " unstow Remove all symlinks" + @echo " import Import new app configs into repo (fzf selector)" @echo "" @echo "Examples:" @echo " make stow dwm # Fresh DWM install" @echo " make stow hyprland # Fresh Hyprland install" @echo " make restow dwm # Refresh DWM links after git pull" - @echo " make adopt hyprland # Resolve conflicts, keep repo version" + @echo " make reset hyprland # Resolve conflicts, keep repo version" + @echo " make import # Select configs to import (no DE needed)" @echo "" # Prevent 'dwm' and 'hyprland' from being treated as file targets @@ -59,12 +61,12 @@ restow: check-de @cd $(DOTFILES) && $(STOW) --restow $(DE) @echo "Done." -# Adopt - pull system files into repo, then reset to repo version -adopt: check-de - @echo "Adopting common + $(DE)..." +# Reset - resolve conflicts by adopting then reverting to repo version +reset: check-de + @echo "Resetting common + $(DE)..." @cd $(DOTFILES) && $(STOW) --adopt common @cd $(DOTFILES) && $(STOW) --adopt $(DE) - @echo "Resetting adopted files to repo version..." + @echo "Reverting adopted files to repo version..." @git checkout -- dotfiles/ @echo "Done. Symlinks created, repo unchanged." @@ -74,3 +76,33 @@ unstow: check-de @cd $(DOTFILES) && $(STOW) --delete common @cd $(DOTFILES) && $(STOW) --delete $(DE) @echo "Done." + +# Import - select and import new app configs into repo +import: + @echo "Select directories to import (Tab to multi-select, Enter to confirm):" + @echo "" + @selections=$$({ \ + find $(HOME)/.config -maxdepth 1 -mindepth 1 -type d 2>/dev/null | sed 's|$(HOME)/||'; \ + find $(HOME)/.local -maxdepth 2 -mindepth 1 -type d 2>/dev/null | sed 's|$(HOME)/||'; \ + } | sort -u | fzf --multi --prompt="Import> " --header="Select configs to import into dotfiles/common/"); \ + if [ -z "$$selections" ]; then \ + echo "No selections made."; \ + exit 0; \ + fi; \ + echo ""; \ + for dir in $$selections; do \ + src="$(HOME)/$$dir"; \ + dest="$(DOTFILES)/common/$$dir"; \ + if [ -d "$$dest" ]; then \ + echo "Skipping $$dir (already exists in dotfiles)"; \ + else \ + echo "Importing $$dir..."; \ + mkdir -p "$$(dirname $$dest)"; \ + mv "$$src" "$$dest"; \ + fi; \ + done; \ + echo ""; \ + echo "Restowing common..."; \ + cd $(DOTFILES) && $(STOW) --restow common; \ + echo ""; \ + echo "Done. Don't forget to: git add -A && git commit" |
