function __malallai_java_version {
    if [ ! $(command -v java) ] ; then
        echo "" && return 0
    fi
    local prompted=${$(java --version | head -n 1 | awk '{print $2}')##*( )}
    if [ ! $prompted ] ; then
        echo "" && return 0
    fi
    echo "${ZSH_JAVA_PROMPT_PREFIX}${prompted}${ZSH_JAVA_PROMPT_SUFFIX}"
}

function __malallai_venv_version {
    if [ ! $(command -v venv) ] ; then
        echo "" && return 0
    fi
    local prompted=${$(virtualenv_prompt_info)##*( )}
    if [ ! $prompted ] ; then
        echo "" && return 0
    fi
    echo " ${prompted}"
}

function __malallai_pyenv_version {
    if [ ! $(command -v pyenv) ] ; then
        echo "" && return 0
    fi
    local prompted=${$(pyenv_prompt_info)##*( )}
    if [ ! $prompted ] ; then
        echo "" && return 0
    fi
    echo "${ZSH_THEME_PYENV_PREFIX}${prompted}${ZSH_THEME_PYENV_SUFFIX}"
}

function __malallai_ruby_version {
    if [ ! $(command -v ruby) ] ; then
        echo "" && return 0
    fi
    local prompted=${$(ruby_prompt_info)##*( )}
    if [ ! $prompted ] ; then
        echo "" && return 0
    fi
    echo " ${prompted}"
}

function __malallai_nvm_version {
    if [ ! $(command -v nvm) ] ; then
        echo "" && return 0
    fi
    local prompted=${$(nvm_prompt_info)##*( )}
    if [ ! $prompted ] ; then
        echo "" && return 0
    fi
    echo " ${prompted}"
}

function __malallai_py_version {
    local pyenv_prompt=$(__malallai_pyenv_version)
    if [ $pyenv_prompt ] ; then
        echo $pyenv_prompt && return 0
    fi
    local venv_prompt=$(__malallai_venv_version)
    if [ $venv_prompt ] ; then
        echo $venv_prompt && return 0
    fi
    echo "" && return 0
}

function __malallai_git_branch {
    if [ ! $(command -v git) ] ; then
        echo "" && return 0
    fi
    local prompted=${$(git_prompt_info)##*( )}
    if [ ! $prompted ] ; then
        echo "" && return 0
    fi
    echo " ${prompted}"
}

CACHE_FILE="/tmp/deep_search_cache.txt"
DELIMITER=";"
touch "$CACHE_FILE"

function __combined_deep_search {
    local current_dir="$PWD"
    local iteration="$1"
    local count=0

    # Check if inside a git repository and if so, get the root directory
    git_root=$(git rev-parse --show-toplevel 2>/dev/null)
    if [[ $? -eq 0 && -n "$git_root" ]]; then
        for searched_file in "${@:2}"; do
            if [[ -f "$git_root/$searched_file" ]]; then
                return 0
            fi
        done
    fi

    # Check cache first
    for searched_file in "${@:2}"; do
        cached_path=$(grep -F "$PWD$DELIMITER$searched_file" "$CACHE_FILE" | cut -d"$DELIMITER" -f3)
        if [[ -n "$cached_path" && -f "$cached_path/$searched_file" ]]; then
            return 0
        fi
    done

    # If not in cache or git root, perform the search
    while [[ $count -lt $iteration ]]; do
        for searched_file in "${@:2}"; do
            if [[ -f "$current_dir/$searched_file" ]]; then
                # Update the cache
                echo "$PWD$DELIMITER$searched_file$DELIMITER$current_dir" >> "$CACHE_FILE"
                return 0
            fi
        done
        current_dir=$(dirname "$current_dir")
        count=$((count + 1))
    done

    return 1
}
