mirror of
https://github.com/pyenv/pyenv.git
synced 2024-12-22 21:22:38 +00:00
show all enabled versions (maybe multiple) in pyenv versions
This commit is contained in:
parent
13122ca9bf
commit
e89ae3a4a9
1 changed files with 13 additions and 4 deletions
|
@ -2,24 +2,33 @@
|
|||
set -e
|
||||
[ -n "$PYENV_DEBUG" ] && set -x
|
||||
|
||||
array_exists() {
|
||||
local x car="$1"
|
||||
shift
|
||||
for x in "$@"; do
|
||||
[ "${x}" = "${car}" ] && return 0
|
||||
done
|
||||
return 1
|
||||
}
|
||||
|
||||
IFS=: PYENV_VERSION_NAMES=($(pyenv-version-name))
|
||||
|
||||
if [ "$1" = "--bare" ]; then
|
||||
hit_prefix=""
|
||||
miss_prefix=""
|
||||
print_version="$PYENV_VERSION_NAMES"
|
||||
version_origin=""
|
||||
else
|
||||
hit_prefix="* "
|
||||
miss_prefix=" "
|
||||
print_version="$PYENV_VERSION_NAMES (set by $(pyenv-version-origin))"
|
||||
version_origin=" (set by $(pyenv-version-origin))"
|
||||
fi
|
||||
|
||||
for path in "${PYENV_ROOT}/versions/"*; do
|
||||
if [ -d "$path" ]; then
|
||||
version="${path##*/}"
|
||||
|
||||
if [ "$version" == "$PYENV_VERSION_NAMES" ]; then
|
||||
echo "${hit_prefix}${print_version}"
|
||||
if array_exists "$version" "${PYENV_VERSION_NAMES[@]}"; then
|
||||
echo "${hit_prefix}${version}${version_origin}"
|
||||
else
|
||||
echo "${miss_prefix}${version}"
|
||||
fi
|
||||
|
|
Loading…
Reference in a new issue