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