- GNU Stow packages: kitty, fish, nvim, btop, fastfetch, starship, git, claude - install.sh with modular install, template rendering, fish plugins setup - uninstall.sh (stow -D) and scripts/doctor.sh for health checks - Brewfile (macOS) + Aptfile (Linux servers) - Claude Code hooks pipeline: settings.json.tpl, Obsidian session logging scripts - memory-compiler inline copy with env-var-based paths - Python scripts patched: os.environ.get() for OBSIDIAN_VAULT + PROJECTS_ROOT - fish/config.fish: platform-aware Homebrew PATH (macOS + Linuxbrew) - .env.example template for ~/.dotfiles.env Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
42 lines
1.2 KiB
Bash
42 lines
1.2 KiB
Bash
#!/usr/bin/env bash
|
|
# lib/stow.sh — GNU Stow wrapper with conflict backup
|
|
|
|
# ensure_stow — install stow if missing
|
|
ensure_stow() {
|
|
if has_cmd stow; then return 0; fi
|
|
warn "stow not found — installing..."
|
|
if is_macos; then
|
|
brew install stow
|
|
else
|
|
sudo apt-get install -y stow
|
|
fi
|
|
}
|
|
|
|
# stow_package REPO_DIR MODULE
|
|
# Symlinks MODULE package from REPO_DIR into $HOME using stow --no-folding.
|
|
# Backs up any conflicting real files before stowing.
|
|
stow_package() {
|
|
local repo_dir="$1"
|
|
local module="$2"
|
|
local pkg_dir="$repo_dir/$module"
|
|
|
|
[[ -d "$pkg_dir" ]] || { warn "Package '$module' not found in repo — skipping."; return 0; }
|
|
|
|
# Find potential conflicts (real files at the target location)
|
|
while IFS= read -r rel; do
|
|
local target="$HOME/${rel#"$pkg_dir/"}"
|
|
backup_file "$target"
|
|
done < <(find "$pkg_dir" -type f -not -path "*/.git/*")
|
|
|
|
stow --no-folding -d "$repo_dir" -t "$HOME" "$module"
|
|
success "Stowed: $module"
|
|
}
|
|
|
|
# unstow_package REPO_DIR MODULE
|
|
unstow_package() {
|
|
local repo_dir="$1"
|
|
local module="$2"
|
|
[[ -d "$repo_dir/$module" ]] || { warn "Package '$module' not found — skipping."; return 0; }
|
|
stow -D -d "$repo_dir" -t "$HOME" "$module"
|
|
success "Unstowed: $module"
|
|
}
|