diff --git a/.config/fish/config.fish b/.config/fish/config.fish index c9810ad..e6c2588 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.6" +set -g DOTFILES_VERSION "1.0.7" # --- Remote repository (set this to enable auto-updates) -------------------- # Example: diff --git a/.config/fish/functions/dotfiles.fish b/.config/fish/functions/dotfiles.fish index d722bfc..27126ff 100644 --- a/.config/fish/functions/dotfiles.fish +++ b/.config/fish/functions/dotfiles.fish @@ -403,10 +403,8 @@ end # 3. Copies the templates from the cloned repo into DOTFILES_DIR # 4. Re-applies every template to its target location # -# The config.fish itself is NOT overwritten — that would require a shell -# restart to take effect. Instead, sync copies the *templates* from the -# upstream repo, then re-applies them. To update the framework logic -# itself (the *.fish files), run the update command shown after sync. +# Sync also copies config.fish and functions/ from upstream, then +# automatically restarts the shell if framework files changed. # ══════════════════════════════════════════════════════════════════════════════ function dotfiles_sync -d "Pull remote updates and re-apply all dotfiles" @@ -453,18 +451,36 @@ function dotfiles_sync -d "Pull remote updates and re-apply all dotfiles" echo "Re-applying dotfiles ..." dotfiles_update - # ── Step 5: Clean up ─────────────────────────────────────────────────── + # ── Step 5: Copy framework files (config.fish, functions/) ───────────── + echo "" + echo "Updating framework files ..." + set -l had_updates 0 + if test -f "$tmpdir/.config/fish/config.fish" + command cp "$tmpdir/.config/fish/config.fish" "$__fish_config_dir/config.fish" + echo " config.fish updated" + set had_updates 1 + end + if test -d "$tmpdir/.config/fish/functions" + command cp -r "$tmpdir/.config/fish/functions/." "$__fish_config_dir/functions/" + echo " functions/ updated" + set had_updates 1 + end + + # ── Step 6: Clean up ─────────────────────────────────────────────────── command rm -rf "$tmpdir" echo "" echo "Sync complete." echo "" - echo "NOTE: framework updates (config.fish, functions/) require a manual" - echo "copy and shell restart. To apply them:" - echo "" - echo " git clone $DOTFILES_REPO_URL /tmp/dotfiles-update" - echo " cp -r /tmp/dotfiles-update/.config/fish/config.fish ~/.config/fish/" - echo " cp -r /tmp/dotfiles-update/.config/fish/functions/ ~/.config/fish/" - echo " exec fish" + + # ── Step 7: Restart shell to apply framework changes ─────────────────── + if test "$had_updates" -eq 1 + if status is-interactive + echo "Restarting shell to apply changes ..." + exec fish + else + echo "Framework files updated. Restart your shell: exec fish" + end + end end