#!/usr/bin/env bash # # Summary: List all Python virtualenvs found in `$PYENV_ROOT/versions/*'. # # Usage: pyenv virtualenvs [--bare] # set -e [ -n "$PYENV_DEBUG" ] && set -x if [ -z "$PYENV_ROOT" ]; then PYENV_ROOT="${HOME}/.pyenv" fi unset BARE if [ "$1" = "--bare" ]; then BARE=true fi print_version() { local version="$1" if [ -n "${BARE}" ]; then echo "${version}" else local prefix="$(pyenv-virtualenv-prefix "${version}")" echo "${version} (created from ${prefix:-unknown})" fi } versions=($(pyenv-versions --bare)) for version in "${versions[@]}"; do prefix="$(pyenv-prefix "${version}")" if [ -f "${prefix}/bin/activate" ]; then print_version "${version}" fi done