Capture your current install info
| #!/bin/zsh | |
| # Always run in zsh, even if started with "sh" or "bash" | |
| if [ -z "$ZSH_VERSION" ]; then exec /bin/zsh "$0" "$@"; fi | |
| # ===================================================================== | |
| # capture.sh - STEP 1. Run this on your OLD Mac. | |
| # | |
| # Creates two things in this folder: | |
| # install-list.txt The ONE list of everything to put on the new Mac: | |
| # apps, command-line tools, libraries, global | |
| # packages, editor extensions and app settings. | |
| # Delete any line you don't want. | |
| # Settings/ Copies of the app settings listed below. | |
| # | |
| # Usage: zsh capture.sh | |
| # ===================================================================== | |
| # ---- App settings to capture (edit freely) -------------------------- | |
| # One entry per app: "Name|path|path|..." Paths must start with ~ | |
| # "defaults:" saves an app's preferences file. | |
| # Entries whose paths don't exist on this Mac are skipped automatically. | |
| SETTINGS=( | |
| "Final Cut Pro|~/Movies/Motion Templates.localized|~/Library/Application Support/ProApps|~/Library/Application Support/Final Cut Pro" | |
| "Compressor|~/Library/Application Support/Compressor" | |
| "Fonts|~/Library/Fonts" | |
| "Audio plug-ins|~/Library/Audio/Plug-Ins" | |
| "VS Code|~/Library/Application Support/Code/User/settings.json|~/Library/Application Support/Code/User/keybindings.json|~/Library/Application Support/Code/User/snippets" | |
| "Cursor|~/Library/Application Support/Cursor/User/settings.json|~/Library/Application Support/Cursor/User/keybindings.json|~/Library/Application Support/Cursor/User/snippets" | |
| "Git|~/.gitconfig|~/.gitignore_global" | |
| "SSH config|~/.ssh/config" | |
| ) | |
| # --------------------------------------------------------------------- | |
| cd "${0:A:h}" || exit 1 | |
| HERE=$PWD | |
| LIST="$HERE/install-list.txt" | |
| WORK="$HERE/.capture" | |
| rm -rf "$WORK"; mkdir -p "$WORK" | |
| # Make sure tools installed by Homebrew, mise, cargo, uv and pipx are findable | |
| [[ -x /opt/homebrew/bin/brew ]] && eval "$(/opt/homebrew/bin/brew shellenv)" | |
| for d in "$HOME/.local/share/mise/shims" "$HOME/.cargo/bin" "$HOME/.local/bin"; do | |
| [[ -d $d ]] && path=("$d" $path) | |
| done | |
| [[ -s $HOME/.nvm/nvm.sh ]] && ! command -v npm >/dev/null && source "$HOME/.nvm/nvm.sh" >/dev/null 2>&1 | |
| have() { command -v "$1" >/dev/null 2>&1 } | |
| plist() { /usr/libexec/PlistBuddy -c "Print :$2" "$1/Contents/Info.plist" 2>/dev/null } | |
| emit() { printf '%-9s| %-34s| %s\n' "$2" "$3" "$4" >> "$WORK/$1.txt" } # section type key notes | |
| if ! have jq; then | |
| have brew && brew install jq >/dev/null 2>&1 | |
| have jq || { echo "This script needs jq. Install Homebrew, then run: brew install jq"; exit 1; } | |
| fi | |
| [[ -f $LIST ]] && cp "$LIST" "$HERE/install-list.previous.txt" && echo "Your previous list was saved as install-list.previous.txt" | |
| # ===================================================================== | |
| print -P "\n%B1/4 Apps%b" | |
| # ===================================================================== | |
| # Apps already installed through Homebrew | |
| typeset -A CASK_FOR_APP FDESC API_CASK API_DESC SEEN_CASK MAS_ID | |
| if have brew; then | |
| brew info --json=v2 --installed > "$WORK/brew-installed.json" 2>/dev/null | |
| while IFS= |