# shellcheck shell=bash

___x_cmd_ohmyposh_load___main(){
    local shellname="${1:-$___X_CMD_SHELL}"
    case "$shellname" in
        zsh) ;;
        bash)
            [ "${BASH_VERSINFO[0]}" -ge 4 ] || {
                ohmyposh:warn "There may be syntax issues with the current version of bash. It's recommended to update bash for better compatibility."
                return 1
            }
            ;;
        *)  ohmyposh:warn "Todo"; return 1 ;;
    esac
    eval "$( ___x_cmd_ohmyposh_run init "$shellname" --print || printf "%s\n" "false" )" || return $?

    if [ -n "$ZSH_VERSION" ]; then
        local x_=; ___x_cmd_ohmyposh_feature_get_ zshplugin || return $?
        ohmyposh:debug "The ohmyposh [feature=zshplugin] is '$x_'"
        [ "$x_" = never ] || ___x_cmd zshplugin load
    fi
}

___x_cmd_ohmyposh_load___applyfile(){
    local name="$1"
    local x_=; ___x_cmd_ohmyposh_which_ "$name" || return $?
    export POSH_THEME="$x_"
}

___x_cmd_ohmyposh_load___applyfile0(){
    ___x_cmd_theme_boot current_vendor_unset
    unset POSH_THEME
}

___x_cmd_ohmyposh___shellconfig(){
    local shellname="$1"
    local name="$2"
    local x_=; ___x_cmd_ohmyposh_which_ "$name" || return $?
    POSH_THEME="$x_" ___x_cmd_ohmyposh_run init "$shellname" --print
}
