feat: auto-detect and install missing shell frameworks after restore
After mackup restores dotfiles, ~/.zshrc may reference tools (Oh My Zsh,
nvm, pyenv, rustup, …) that haven't been installed yet, causing errors on
first shell login.
lib/shell.sh:
- Defines 13 built-in frameworks with detect + install commands
- Scans ~/.zshrc / ~/.bashrc etc. for references before installing
(avoids installing things the user doesn't actually use)
- SSR_SHELL_DEPS_EXTRA in ssr.conf for custom user additions
bin/ssr-restore:
- Adds `shell_deps` as a resumable step after mackup_restore
- Sources ~/.config/ssr/post-restore.sh if present (user hook)
config/post-restore.sh.example:
- Template with commented examples (OMZ plugins, npm globals, SSH keys)
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -23,6 +23,8 @@ source "$SSR_ROOT/lib/macos-prefs.sh"
|
||||
source "$SSR_ROOT/lib/restore-state.sh"
|
||||
# shellcheck source=../lib/icloud.sh
|
||||
source "$SSR_ROOT/lib/icloud.sh"
|
||||
# shellcheck source=../lib/shell.sh
|
||||
source "$SSR_ROOT/lib/shell.sh"
|
||||
|
||||
ssr::require_macos
|
||||
ssr::load_config
|
||||
@@ -100,6 +102,14 @@ ssr::rs::run mackup_restore "Mackup restore" _ssr_mackup_restore_step
|
||||
# by Mackup (com.apple.dock.plist etc.) without requiring a logout.
|
||||
ssr::macos::restart_ui
|
||||
|
||||
# After dotfiles are in place, install any shell frameworks / version
|
||||
# managers they reference that aren't already present (e.g. Oh My Zsh).
|
||||
if [[ "${SSR_SHELL_DEPS_ENABLED:-true}" == "true" ]]; then
|
||||
ssr::rs::run shell_deps "Shell framework deps" ssr::shell::detect_and_install
|
||||
else
|
||||
ssr::rs::set "step_shell_deps" "skipped"
|
||||
fi
|
||||
|
||||
ssr::rs::run macos_defaults "macOS defaults" ssr::macos::apply_defaults
|
||||
|
||||
if [[ "${SSR_SNAPSHOT_MACOS_PREFS:-true}" == "true" ]]; then
|
||||
@@ -112,6 +122,20 @@ fi
|
||||
# resumable step — it's side-effect-only and always safe to re-run).
|
||||
ssr::macos::open_installed_casks
|
||||
|
||||
# --- User-defined post-restore hook --------------------------------------
|
||||
# Sources ~/.config/ssr/post-restore.sh when present.
|
||||
# Copy config/post-restore.sh.example from the repo as a starting point.
|
||||
_user_hook="${SSR_CONFIG_DIR:-$HOME/.config/ssr}/post-restore.sh"
|
||||
if [[ -f "$_user_hook" ]]; then
|
||||
ssr::log "Running post-restore hook: $_user_hook"
|
||||
# shellcheck source=/dev/null
|
||||
source "$_user_hook" \
|
||||
&& ssr::ok "post-restore hook completed" \
|
||||
|| ssr::warn "post-restore hook exited with errors (non-fatal)"
|
||||
else
|
||||
ssr::log "No post-restore hook found (optional: $_user_hook)"
|
||||
fi
|
||||
|
||||
# Mark overall completion time.
|
||||
ssr::rs::set "finished" "$(ssr::ts)"
|
||||
|
||||
|
||||
Reference in New Issue
Block a user