function bkp --description 'Log Fedora apps and sync to Git'
    set -l SOURCE (chezmoi source-path)

    echo "Logging installed applications..."
    
    # 1. Export DNF packages (Manually installed only)
    # Prefer 'dnf repoquery --userinstalled' when available (shows user-installed packages).
    if dnf repoquery --userinstalled --qf '%{name}\n' > /dev/null 2>&1
        dnf repoquery --userinstalled --qf '%{name}\n' > "$SOURCE/apps-dnf.txt"
    else
        # Fallback: list all installed RPMs (includes dependencies)
        rpm -qa --qf '%{NAME}\n' | sort -u > "$SOURCE/apps-dnf.txt"
    end

    # 2. Export Flatpaks
    flatpak list --app --columns=application > "$SOURCE/apps-flatpak.txt"

    # 3. Export VS Code extensions
    if command -v code > /dev/null
        code --list-extensions > "$SOURCE/vscode-extensions.txt"
    end

    # 4. Sync to Git
    echo "Pushing to Hestia (Forgejo)..."
    cd "$SOURCE"
    # Ensure the remote has an 'origin' remote; add default if missing
    if not contains origin (git remote)
        git remote add origin git@git.breadway.dev:Breadway/dotfiles.git
    end
    git add .
    set -l _ts (date "+%Y-%m-%d %H:%M")
    git commit -m "Update Fedora state: $_ts" || true
    # Push current branch to origin (don't assume 'main')
    git push origin HEAD
    cd - >/dev/null

    echo "System state backed up."
end
