#!/bin/bash URL="https://gitlab.com/alexandre_lestruhaut/dotfiles/-/archive/main/dotfiles-main.zip?ref_type=heads" GITURL="https://gitlab.com/alexandre_lestruhaut/dotfiles.git" OUTPUT="$HOME/.dotfiles" # 1. Ensure stow is installed before proceeding if ! command -v stow >/dev/null 2>&1; then echo "Error: 'stow' is required but not installed. Please install it first." >&2 exit 1 fi # 2. Create output directory if it doesn't exist (or handle if it does) if [ -d "$OUTPUT" ]; then echo "Directory $OUTPUT already exists. Skipping download/clone." else if command -v git >/dev/null 2>&1; then git clone "$GITURL" "$OUTPUT" elif command -v wget >/dev/null 2>&1 || command -v curl >/dev/null 2>&1; then mkdir -p "$OUTPUT" TEMP_ZIP="/tmp/dotfiles.zip" if command -v wget >/dev/null 2>&1; then wget -O "$TEMP_ZIP" "$URL" else curl -L -o "$TEMP_ZIP" "$URL" fi unzip "$TEMP_ZIP" -d "$OUTPUT" # GitLab ZIPs usually wrap files in a subfolder (e.g., dotfiles-main/) # You might need to move files up one level here depending on the ZIP structure rm "$TEMP_ZIP" else echo "Error: Neither git, wget, nor curl is installed." >&2 exit 1 fi fi # 3. Execution cd "$OUTPUT" || exit 1 # Using --target=$HOME ensures stow links to your home dir regardless of where the script runs stow --target="$HOME" . --dotfiles echo "Dotfiles deployed successfully!"