From 84dc253f2b65ebf15a2d0e4397b4979a79e9b29b Mon Sep 17 00:00:00 2001 From: Jose Jimenez Date: Sun, 25 Jan 2026 11:29:43 +0100 Subject: [PATCH] Fix curl one-line install --- install.sh | 47 +++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 41 insertions(+), 6 deletions(-) diff --git a/install.sh b/install.sh index 377adfd..8cc1aad 100755 --- a/install.sh +++ b/install.sh @@ -1,6 +1,34 @@ #!/usr/bin/env bash set -e +# ==================== +# Logging (early definitions for clone step) +# ==================== +log_info() { echo "[INFO] $*"; } +log_warn() { echo "[WARN] $*"; } +log_error() { echo "[ERROR] $*" >&2; } + +# ==================== +# Detect installation method and setup DOTFILES_DIR +# ==================== +if [ -f "$(dirname "$0")/zsh/zshrc" ]; then + # Running from cloned repo + DOTFILES_DIR="$(cd "$(dirname "$0")" && pwd)" + CLEANUP_DOTFILES=false + log_info "Running from cloned repository at $DOTFILES_DIR" +else + # Running from curl, need to clone + DOTFILES_DIR="$HOME/.dotfiles-tmp" + CLEANUP_DOTFILES=true + + log_info "Running from curl, cloning dotfiles repository..." + + rm -rf "$DOTFILES_DIR" + git clone https://github.com/jjsalinas/dotfiles.git "$DOTFILES_DIR" + + log_info "Repository cloned to temporary location: $DOTFILES_DIR" +fi + # ==================== # Defaults # ==================== @@ -8,19 +36,14 @@ THEME="clean" ADD_NVM=false DRY_RUN=false -DOTFILES_DIR="$(cd "$(dirname "$0")" && pwd)" ZSH_DIR="$HOME/.zsh" ZSHRC="$HOME/.zshrc" ZSHRC_LOCAL="$HOME/.zshrc.local" ZSH_CUSTOM="${ZSH_CUSTOM:-$HOME/.oh-my-zsh/custom}" # ==================== -# Logging +# Helper functions # ==================== -log_info() { echo "[INFO] $*"; } -log_warn() { echo "[WARN] $*"; } -log_error() { echo "[ERROR] $*" >&2; } - run() { if $DRY_RUN; then log_info "[dry-run] $*" @@ -176,6 +199,18 @@ else log_info "[dry-run] would write ~/.zshrc.local with theme $THEME" fi +# ==================== +# Cleanup +# ==================== +if $CLEANUP_DOTFILES; then + log_info "Cleaning up temporary files" + if ! $DRY_RUN; then + rm -rf "$DOTFILES_DIR" + else + log_info "[dry-run] would remove $DOTFILES_DIR" + fi +fi + # ==================== # Done # ====================