auroraad02f78
install.sh: stow, delete conflicting files if they exist
+37 −4
1 file changed
- M install.sh +37 −4
| @@ -122,10 +122,7 @@ pkg_aur=( | |||
| 122 | 122 | ||
| 123 | 123 | ||
| 124 | 124 | # 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[@]}" | |
| 129 | 126 | ||
| 130 | 127 | # Install dev tools | |
| 131 | 128 | read -rp "Do you wish to development tools? [y/n]" install_dev_tools | |
| @@ -163,3 +160,39 @@ if [[ $install_aur_pkg == y ]]; then | |||
| 163 | 160 | # Install aur packages | |
| 164 | 161 | paru -S --needed "${pkg_aur[@]}" | |
| 165 | 162 | 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 | |