#!/usr/bin/env bash set -euo pipefail repo_root="$(cd "$(dirname "$0")/.." && pwd)" out_dir="${1:-$repo_root/inventory/current}" mkdir -p "$out_dir" run_to_file() { local name="$1" shift "$@" >"$out_dir/$name" } run_shell_to_file() { local name="$1" local cmd="$2" bash -lc "$cmd" >"$out_dir/$name" } cat >"$out_dir/README.md" </dev/null || true" run_to_file home-top-level.txt find "$HOME" -maxdepth 1 -mindepth 1 run_to_file home-top-level-dirs.txt find "$HOME" -maxdepth 1 -mindepth 1 -type d run_to_file home-top-level-files.txt find "$HOME" -maxdepth 1 \( -type f -o -type l \) run_to_file dot-config-top.txt find "$HOME/.config" -maxdepth 2 -mindepth 1 run_to_file library-application-support-top.txt find "$HOME/Library/Application Support" -maxdepth 1 -mindepth 1 -type d run_to_file library-preferences-top.txt find "$HOME/Library/Preferences" -maxdepth 1 -type f run_to_file repos-github.txt find "$HOME/Documents/GitHub" -maxdepth 1 -mindepth 1 -type d run_shell_to_file repos-outside-github.txt "find \"$HOME\" -maxdepth 3 -type d -name .git 2>/dev/null | sed 's#/.git\$##' | sort" if command -v brew >/dev/null 2>&1; then run_shell_to_file brew-bundle.txt "brew bundle dump --force --file=-" run_shell_to_file brew-formulae.txt "brew list --formula" run_shell_to_file brew-casks.txt "brew list --cask" run_shell_to_file brew-leaves.txt "HOMEBREW_NO_AUTO_UPDATE=1 brew leaves | sort" run_shell_to_file brew-services.txt "brew services list" fi if command -v npm >/dev/null 2>&1; then run_shell_to_file npm-global.txt "npm ls -g --depth=0 2>/dev/null || true" fi if command -v pnpm >/dev/null 2>&1; then run_shell_to_file pnpm-global.txt "pnpm ls -g --depth=0 2>/dev/null || true" fi if command -v pipx >/dev/null 2>&1; then run_shell_to_file pipx.txt "pipx list 2>/dev/null || true" fi if command -v uv >/dev/null 2>&1; then run_shell_to_file uv-tools.txt "uv tool list 2>/dev/null || true" fi if command -v cargo >/dev/null 2>&1; then run_shell_to_file cargo-installs.txt "cargo install --list 2>/dev/null || true" run_shell_to_file cargo-bin.txt "ls -1 \"$HOME/.cargo/bin\" 2>/dev/null | sort" fi if command -v go >/dev/null 2>&1; then run_shell_to_file go-env.txt "go env" run_shell_to_file go-bin.txt "ls -1 \"\$(go env GOPATH 2>/dev/null)/bin\" 2>/dev/null | sort" fi if command -v python3 >/dev/null 2>&1; then run_shell_to_file python-user-packages.txt "python3 -m pip list --user --format=freeze 2>/dev/null || true" fi if command -v gem >/dev/null 2>&1; then run_shell_to_file ruby-gems.txt "gem list 2>/dev/null || true" fi if command -v nix >/dev/null 2>&1; then run_shell_to_file nix-profile.txt "nix --extra-experimental-features 'nix-command flakes' profile list 2>/dev/null || true" fi echo "Wrote snapshot to $out_dir"