#!/bin/bash

check_venv() {
    pip=$(which pip3)
    if [ -z "$pip" ]; then
        echo "pip3 not found"
        return 1
    fi
    pipenv=$("$pip" -V 2>&1)
    cwd=$(pwd)
    if [[ "$pipenv" == *"$cwd"* ]]; then
        result=$(echo "$pipenv" | sed -E 's|.*/([^/]+)/venv/lib/[^/]+/site-packages/pip.*|\1|')
        echo $result
    else
        echo ""
    fi

}

check_venv