2011-08-12 05:33:45 -04:00
|
|
|
#!/usr/bin/env bash
|
2012-12-29 13:06:20 -05:00
|
|
|
# Summary: List all available rbenv commands
|
|
|
|
# Usage: rbenv commands [--sh|--no-sh]
|
|
|
|
|
2011-08-12 05:33:45 -04:00
|
|
|
set -e
|
2011-09-12 11:11:59 -04:00
|
|
|
[ -n "$RBENV_DEBUG" ] && set -x
|
2011-08-03 23:20:01 -04:00
|
|
|
|
2011-09-13 13:48:49 -04:00
|
|
|
# Provide rbenv completions
|
|
|
|
if [ "$1" = "--complete" ]; then
|
2011-09-13 14:12:04 -04:00
|
|
|
echo --sh
|
|
|
|
echo --no-sh
|
2011-09-13 13:48:49 -04:00
|
|
|
exit
|
|
|
|
fi
|
|
|
|
|
2011-08-23 12:34:03 -04:00
|
|
|
if [ "$1" = "--sh" ]; then
|
|
|
|
sh=1
|
|
|
|
shift
|
2011-09-13 13:48:49 -04:00
|
|
|
elif [ "$1" = "--no-sh" ]; then
|
2011-09-06 23:07:05 -04:00
|
|
|
nosh=1
|
|
|
|
shift
|
|
|
|
fi
|
|
|
|
|
2022-10-09 08:48:13 -04:00
|
|
|
IFS=: read -d '' -r -a paths <<<"$PATH" || true
|
2013-02-24 08:52:50 -05:00
|
|
|
|
2011-08-03 23:20:01 -04:00
|
|
|
shopt -s nullglob
|
|
|
|
|
2013-02-24 08:52:50 -05:00
|
|
|
{ for path in "${paths[@]}"; do
|
2011-08-03 23:20:01 -04:00
|
|
|
for command in "${path}/rbenv-"*; do
|
2011-08-23 12:34:03 -04:00
|
|
|
command="${command##*rbenv-}"
|
|
|
|
if [ -n "$sh" ]; then
|
2017-06-23 18:12:09 -04:00
|
|
|
if [ "${command:0:3}" = "sh-" ]; then
|
|
|
|
echo "${command##sh-}"
|
2011-08-23 12:34:03 -04:00
|
|
|
fi
|
2011-09-06 23:07:05 -04:00
|
|
|
elif [ -n "$nosh" ]; then
|
2017-06-23 18:12:09 -04:00
|
|
|
if [ "${command:0:3}" != "sh-" ]; then
|
|
|
|
echo "${command##sh-}"
|
2011-08-23 12:34:03 -04:00
|
|
|
fi
|
2011-09-06 23:07:05 -04:00
|
|
|
else
|
2017-06-23 18:12:09 -04:00
|
|
|
echo "${command##sh-}"
|
2011-08-23 12:34:03 -04:00
|
|
|
fi
|
2011-08-03 23:20:01 -04:00
|
|
|
done
|
|
|
|
done
|
|
|
|
} | sort | uniq
|