#!/bin/bash set -euo pipefail DOTFILES_REPO="https://gitea.portal.tulsacounty.org/ifoster/dotfiles" DOTFILES_DIR="$HOME/.dotfiles" declare -A FILES_TO_LINK=( [".bashrc"]="$HOME/.bashrc" [".bash_aliases"]="$HOME/.bash_aliases" [".inputrc"]="$HOME/.inputrc" [".gitconfig"]="$HOME/.gitconfig" ) # Clone or update the repo if [ -d "$DOTFILES_DIR/.git" ]; then echo "Updating existing dotfiles repo..." git -C "$DOTFILES_DIR" pull --quiet else echo "Cloning dotfiles into $DOTFILES_DIR..." git clone "$DOTFILES_REPO" "$DOTFILES_DIR" fi # Symlink each file safely for file in "${!FILES_TO_LINK[@]}"; do target="${FILES_TO_LINK[$file]}" source="$DOTFILES_DIR/$file" if [ -L "$target" ]; then echo "✔ Symlink already exists: $target" elif [ -e "$target" ]; then echo "⚠️ Backing up existing file: $target -> ${target}.bak" mv "$target" "${target}.bak" ln -s "$source" "$target" echo "🔗 Linked: $source → $target" else ln -s "$source" "$target" echo "🔗 Linked: $source → $target" fi done # Optionally source the new bashrc if [[ $- == *i* ]]; then echo "Reloading Bash config..." source ~/.bashrc fi echo "✅ Dotfiles install complete."