Delete Inactive Themes

Removes all inactive themes.

keep_if_inactive=( twentytwentytwo twentytwentythree )
inactive=( $( wp theme list --status=inactive --skip-plugins --skip-themes --field=name ) )

for theme in ${inactive[@]}; do
        keep_theme=false
        for keep_theme in ${keep_if_inactive[@]}; do
                if [[ "$keep_theme" == "$theme" ]]; then
                        keep_theme=true
                fi
        done
        if [[ "$keep_theme" != "true" ]]; then
                wp theme delete $theme --skip-plugins --skip-themes
        fi
done

Replace keep_if_inactive with list of themes you wish to keep. WordPress recommends at least 1 default theme