diff --git a/.config/fish/config.fish b/.config/fish/config.fish index fea9e0b..c9810ad 100644 --- a/.config/fish/config.fish +++ b/.config/fish/config.fish @@ -38,7 +38,7 @@ # DOTFILES_DIR holds the template files; DOTFILES_BACKUP_DIR holds backups # and the last-update-check timestamp. -set -g DOTFILES_VERSION "1.0.5" +set -g DOTFILES_VERSION "1.0.6" # --- Remote repository (set this to enable auto-updates) -------------------- # Example: diff --git a/.config/fish/functions/dotfiles.fish b/.config/fish/functions/dotfiles.fish index b0fd2a5..d722bfc 100644 --- a/.config/fish/functions/dotfiles.fish +++ b/.config/fish/functions/dotfiles.fish @@ -382,11 +382,14 @@ if test -f "$repo_file" set -gx DOTFILES_REPO_URL (command cat "$repo_file") end -# Ensure there's always a default branch, even if config.fish hasn't been -# reloaded after a framework update. +# Ensure there's always a default branch and dotfiles directory, even if +# config.fish hasn't been reloaded after a framework update. if not set -q DOTFILES_REPO_BRANCH set -gx DOTFILES_REPO_BRANCH "main" end +if not set -q DOTFILES_DIR + set -gx DOTFILES_DIR "$__fish_config_dir/dotfiles" +end # ══════════════════════════════════════════════════════════════════════════════ @@ -434,9 +437,11 @@ function dotfiles_sync -d "Pull remote updates and re-apply all dotfiles" if test -d "$upstream_templates" echo "" echo "Updating templates from upstream ..." - # Copy recursively to handle subdirectory templates (e.g. config/). - # We use cp -r and then clean up the destination to only keep files. - command cp -r "$upstream_templates/." "$DOTFILES_DIR/" + if not command cp -r "$upstream_templates/." "$DOTFILES_DIR/" + echo "Error: failed to copy templates to $DOTFILES_DIR" + command rm -rf "$tmpdir" + return 1 + end echo " templates synced from upstream" else echo "Warning: no dotfiles/ directory found in the upstream repo."