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:
@@ -0,0 +1,60 @@
|
||||
#!/usr/bin/env bash
|
||||
# config/post-restore.sh — custom post-restore hooks.
|
||||
#
|
||||
# Copy this file to ~/.config/ssr/post-restore.sh and add your own steps.
|
||||
# It is sourced by `ssr restore` after all built-in steps complete.
|
||||
#
|
||||
# Available helpers (from lib/common.sh):
|
||||
# ssr::log "message" — info line
|
||||
# ssr::ok "message" — success line
|
||||
# ssr::warn "message" — warning line (non-fatal)
|
||||
# ssr::confirm "prompt" — interactive y/N prompt
|
||||
#
|
||||
# Available variables:
|
||||
# SSR_ROOT — path to the ssr repository
|
||||
# backup_dir — cloud backup directory for this host
|
||||
# mackup_dir — cloud Mackup directory
|
||||
#
|
||||
# EXAMPLES
|
||||
# -------------------------------------------------------------------------
|
||||
|
||||
# --- Custom shell dep (extends SSR_SHELL_DEPS_EXTRA in ssr.conf) ---------
|
||||
# If you prefer the hook-file approach over ssr.conf arrays, add deps here:
|
||||
#
|
||||
# if [[ ! -d "$HOME/.my-custom-tool" ]]; then
|
||||
# ssr::log "Installing my-custom-tool..."
|
||||
# curl -sSL https://example.com/install.sh | bash
|
||||
# fi
|
||||
|
||||
# --- Oh My Zsh plugins not installed via Homebrew ------------------------
|
||||
# Plugins are usually git-cloned into ${ZSH_CUSTOM}/plugins.
|
||||
# Example: zsh-syntax-highlighting
|
||||
#
|
||||
# ZSH_CUSTOM="${ZSH_CUSTOM:-$HOME/.oh-my-zsh/custom}"
|
||||
# if [[ -d "$HOME/.oh-my-zsh" && ! -d "$ZSH_CUSTOM/plugins/zsh-syntax-highlighting" ]]; then
|
||||
# git clone https://github.com/zsh-users/zsh-syntax-highlighting.git \
|
||||
# "$ZSH_CUSTOM/plugins/zsh-syntax-highlighting"
|
||||
# fi
|
||||
|
||||
# --- npm global packages --------------------------------------------------
|
||||
# npm globals are not tracked by Homebrew; restore them here.
|
||||
#
|
||||
# if command -v npm >/dev/null 2>&1; then
|
||||
# npm install -g typescript prettier eslint
|
||||
# fi
|
||||
|
||||
# --- macOS app configuration not covered by Mackup -----------------------
|
||||
# Example: Dock position
|
||||
#
|
||||
# defaults write com.apple.dock orientation -string left
|
||||
# killall Dock
|
||||
|
||||
# --- SSH key import -------------------------------------------------------
|
||||
# Keys are intentionally excluded from Mackup (they are sensitive).
|
||||
# Restore from an encrypted backup or password manager here:
|
||||
#
|
||||
# op item get "SSH Key (personal)" --fields "private key" > "$HOME/.ssh/id_ed25519"
|
||||
# chmod 600 "$HOME/.ssh/id_ed25519"
|
||||
|
||||
# --- GPG key import -------------------------------------------------------
|
||||
# gpg --import /path/to/exported.gpg
|
||||
@@ -73,6 +73,22 @@ SSR_PREFS_CONFLICT_DEFAULT=accept
|
||||
# Set to "true" to skip all conflict prompts and auto-accept everywhere.
|
||||
# SSR_ASSUME_YES=false
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
# Shell framework auto-install (runs after mackup restore)
|
||||
# ---------------------------------------------------------------------------
|
||||
# Detect shell frameworks referenced in dotfiles that are not yet installed
|
||||
# (e.g. oh-my-zsh, nvm, pyenv, rustup, starship, …) and install them.
|
||||
# Set to "false" to skip this step.
|
||||
# SSR_SHELL_DEPS_ENABLED=true
|
||||
|
||||
# Additional custom deps, space-separated, pipe-delimited format:
|
||||
# "name|check_expression|install_command"
|
||||
# Example:
|
||||
# SSR_SHELL_DEPS_EXTRA=(
|
||||
# "my-tool|command -v my-tool|brew install my-tool"
|
||||
# "my-fw|[[ -d ~/.my-fw ]]|curl -sSL https://example.com/install.sh | bash"
|
||||
# )
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
# macOS restore behavior
|
||||
# ---------------------------------------------------------------------------
|
||||
|
||||
Reference in New Issue
Block a user