2019-04-23 10:23:33 -04:00
|
|
|
#!/usr/bin/env bash
|
2013-01-18 17:41:41 +09:00
|
|
|
# Summary: List all available pyenv commands
|
|
|
|
|
# Usage: pyenv commands [--sh|--no-sh]
|
|
|
|
|
|
2012-08-31 15:23:41 +09:00
|
|
|
set -e
|
2026-03-13 04:56:23 -06:00
|
|
|
[[ -n $PYENV_DEBUG ]] && set -x
|
2012-08-31 15:23:41 +09:00
|
|
|
|
|
|
|
|
# Provide pyenv completions
|
2026-03-13 04:56:23 -06:00
|
|
|
if [[ $1 = "--complete" ]]; then
|
2012-08-31 15:23:41 +09:00
|
|
|
echo --sh
|
|
|
|
|
echo --no-sh
|
|
|
|
|
exit
|
|
|
|
|
fi
|
|
|
|
|
|
2026-03-13 04:56:23 -06:00
|
|
|
if [[ $1 = "--sh" ]]; then
|
2013-09-30 18:02:12 +09:00
|
|
|
sh=1
|
2012-08-31 15:23:41 +09:00
|
|
|
shift
|
2026-03-13 04:56:23 -06:00
|
|
|
elif [[ $1 = "--no-sh" ]]; then
|
2012-08-31 15:23:41 +09:00
|
|
|
nosh=1
|
|
|
|
|
shift
|
|
|
|
|
fi
|
|
|
|
|
|
2013-09-30 18:02:12 +09:00
|
|
|
IFS=: paths=($PATH)
|
|
|
|
|
|
2012-08-31 15:23:41 +09:00
|
|
|
shopt -s nullglob
|
|
|
|
|
|
2026-03-13 04:56:23 -06:00
|
|
|
{
|
|
|
|
|
if [[ -n $sh ]]; then
|
|
|
|
|
for path in "${paths[@]}"; do
|
|
|
|
|
for command in "${path}"/pyenv-sh-*; do
|
|
|
|
|
echo "${command##*/pyenv-sh-}"
|
|
|
|
|
done
|
|
|
|
|
done
|
|
|
|
|
else
|
|
|
|
|
for path in "${paths[@]}"; do
|
|
|
|
|
for command in "${path}"/pyenv-*; do
|
|
|
|
|
command="${command##*/pyenv-}"
|
|
|
|
|
if [[ -n $nosh ]]; then
|
|
|
|
|
if [[ ${command:0:3} != "sh-" ]]; then
|
|
|
|
|
echo "$command"
|
|
|
|
|
fi
|
|
|
|
|
else
|
2017-06-24 00:12:09 +02:00
|
|
|
echo "${command##sh-}"
|
2012-08-31 15:23:41 +09:00
|
|
|
fi
|
2026-03-13 04:56:23 -06:00
|
|
|
done
|
2012-08-31 15:23:41 +09:00
|
|
|
done
|
2026-03-13 04:56:23 -06:00
|
|
|
fi
|
|
|
|
|
} | sort -u
|