#!/usr/bin/env bash # Backup macOS application configurations set -euo pipefail DOTFILES_DIR="$HOME/dotfiles" APPS_DIR="$DOTFILES_DIR/macos-apps" TIMESTAMP=$(date +%Y%m%d_%H%M%S) # Colors GREEN='\033[0;32m' YELLOW='\033[1;33m' RED='\033[0;31m' NC='\033[0m' echo -e "${GREEN}Backing up macOS application configurations...${NC}" # Create directories mkdir -p "$APPS_DIR"/{LaunchBar,Hazel,Bartender,preferences} # LaunchBar if [ -d "$HOME/Library/Application Support/LaunchBar" ]; then echo -e "${YELLOW}Backing up LaunchBar...${NC}" # Configuration cp -R "$HOME/Library/Application Support/LaunchBar/Configuration" "$APPS_DIR/LaunchBar/" 2>/dev/null || true # Custom actions (exclude cache) rsync -av --exclude="*.cache" --exclude="*.log" \ "$HOME/Library/Application Support/LaunchBar/Actions" \ "$APPS_DIR/LaunchBar/" 2>/dev/null || true # Preferences cp "$HOME/Library/Preferences/at.obdev.LaunchBar.plist" "$APPS_DIR/preferences/" 2>/dev/null || true echo -e "${GREEN}✓ LaunchBar backed up${NC}" fi # Hazel if [ -d "$HOME/Library/Application Support/Hazel" ]; then echo -e "${YELLOW}Backing up Hazel rules...${NC}" # Rules are stored in a database cp "$HOME/Library/Application Support/Hazel/hazelrules.db" "$APPS_DIR/Hazel/" 2>/dev/null || true # Preferences cp "$HOME/Library/Preferences/com.noodlesoft.Hazel.plist" "$APPS_DIR/preferences/" 2>/dev/null || true echo -e "${GREEN}✓ Hazel rules backed up${NC}" fi # Bartender if [ -d "$HOME/Library/Application Support/Bartender" ]; then echo -e "${YELLOW}Backing up Bartender...${NC}" # Bartender 4 stores settings in preferences cp "$HOME/Library/Preferences/com.surteesstudios.Bartender.plist" "$APPS_DIR/preferences/" 2>/dev/null || true echo -e "${GREEN}✓ Bartender settings backed up${NC}" fi # Export readable versions of plists echo -e "${YELLOW}Converting plists to readable format...${NC}" cd "$APPS_DIR/preferences" for plist in *.plist; do if [ -f "$plist" ]; then plutil -convert xml1 -o "${plist%.plist}.xml" "$plist" 2>/dev/null || true fi done echo -e "${GREEN}Backup complete!${NC}" echo -e "Configs saved to: $APPS_DIR" # Create restore instructions cat > "$APPS_DIR/RESTORE.md" << 'EOF' # Restoring Application Configurations ## LaunchBar 1. Install LaunchBar from cask 2. Quit LaunchBar 3. Copy Configuration: ```bash cp -R ~/dotfiles/macos-apps/LaunchBar/Configuration/* "$HOME/Library/Application Support/LaunchBar/Configuration/" ``` 4. Copy custom actions: ```bash cp -R ~/dotfiles/macos-apps/LaunchBar/Actions/* "$HOME/Library/Application Support/LaunchBar/Actions/" ``` 5. Restore preferences: ```bash cp ~/dotfiles/macos-apps/preferences/at.obdev.LaunchBar.plist ~/Library/Preferences/ ``` ## Hazel 1. Install Hazel from cask 2. Quit Hazel 3. Restore rules database: ```bash cp ~/dotfiles/macos-apps/Hazel/hazelrules.db "$HOME/Library/Application Support/Hazel/" ``` 4. Restore preferences: ```bash cp ~/dotfiles/macos-apps/preferences/com.noodlesoft.Hazel.plist ~/Library/Preferences/ ``` ## Bartender 1. Install Bartender from cask 2. Quit Bartender 3. Restore preferences: ```bash cp ~/dotfiles/macos-apps/preferences/com.surteesstudios.Bartender.plist ~/Library/Preferences/ ``` 4. Restart Bartender ## Note After restoring preferences, you may need to: - Restart the applications - Re-authorize/license the apps - Log out and back in for some settings to take effect EOF