Krolyxon
Commit ad02f78

Branches

Refs →

auroraad02f78

install.sh: stow, delete conflicting files if they exist

Author
krolxon
Date
2025-12-09 15:30 +0530
Parent
0dfb61b
Commit
ad02f786d79003d5b78b6c2104b78f25168b9d00

+37 −4

1 file changed

  1. M install.sh +37 −4
M install.sh View
@@ -122,10 +122,7 @@ pkg_aur=(
122122
123123
124124 # Install necessary desktop packages
125−sudo pacman -S --needed "${pkg_desktop[@]}"
126−
127−# install packages
128−sudo pacman -S --needed "${pkg_utils[@]}"
125+sudo pacman -S --needed "${pkg_desktop[@]}" "${pkg_utils[@]}"
129126
130127 # Install dev tools
131128 read -rp "Do you wish to development tools? [y/n]" install_dev_tools
@@ -163,3 +160,39 @@ if [[ $install_aur_pkg == y ]]; then
163160 # Install aur packages
164161 paru -S --needed "${pkg_aur[@]}"
165162 fi
163+
164+
165+# Setup dotfiles
166+echo "⚠️ WARNING: This will DELETE any conflicting files and replace them with symlinks from this repo."
167+echo " Make sure your dotfiles repo is the source of truth / already backed up."
168+read -rp "Continue with stow (y/N): " confirm
169+if [[ "$confirm" =~ ^[Yy]$ ]]; then
170+ echo "Detecting conflicts..."
171+ conflicts=$(stow . --no-folding -nv 2>&1 | \
172+ sed -n 's/.*existing target \(.*\) since neither.*/\1/p')
173+
174+ if [[ -z "$conflicts" ]]; then
175+ echo "No conflicts. Running stow normally..."
176+ stow . --no-folding
177+ echo "✅ Done."
178+ else
179+ echo "These paths conflict and will be removed:"
180+ printf ' %s\n' $conflicts
181+ read -rp "Proceed with deleting these files? (y/N): " ok
182+ if [[ ! "$ok" =~ ^[Yy]$ ]]; then
183+ echo "Aborted."
184+ fi
185+
186+ # Remove conflicts relative to $HOME
187+ for path in $conflicts; do
188+ echo "Removing $HOME/$path"
189+ rm -rf "$HOME/$path"
190+ done
191+
192+ echo "Running stow..."
193+ stow . --no-folding
194+ echo "✅ Dotfiles stowed with overwrite."
195+ fi
196+else
197+ echo "Aborted"
198+fi