2011-08-03 22:43:40 -04:00
|
|
|
_rbenv_commands() {
|
2011-08-03 21:44:29 -04:00
|
|
|
local cur commands
|
|
|
|
COMPREPLY=()
|
|
|
|
cur="${COMP_WORDS[COMP_CWORD]}"
|
|
|
|
commands="exec prefix rehash set-default set-local version versions\
|
|
|
|
whence which"
|
2011-08-03 21:41:06 -04:00
|
|
|
|
2011-08-03 21:44:29 -04:00
|
|
|
COMPREPLY=( $( compgen -W "$commands" -- $cur ) )
|
2011-08-03 21:41:06 -04:00
|
|
|
}
|
|
|
|
|
2011-08-03 22:43:40 -04:00
|
|
|
_rbenv_versions() {
|
2011-08-03 21:44:29 -04:00
|
|
|
COMPREPLY=()
|
2011-08-03 22:50:03 -04:00
|
|
|
local cur=${COMP_WORDS[COMP_CWORD]}
|
|
|
|
local versions=(system $(rbenv versions --bare))
|
|
|
|
versions="${versions[@]}"
|
2011-08-03 21:41:06 -04:00
|
|
|
|
2011-08-03 22:43:40 -04:00
|
|
|
COMPREPLY=( $( compgen -W "$versions" -- $cur ) )
|
2011-08-03 21:41:06 -04:00
|
|
|
}
|
|
|
|
|
2011-08-03 21:44:29 -04:00
|
|
|
_rbenv() {
|
|
|
|
local cur prev
|
|
|
|
COMPREPLY=()
|
|
|
|
cur="${COMP_WORDS[COMP_CWORD]}"
|
|
|
|
prev="${COMP_WORDS[COMP_CWORD-1]}"
|
2011-08-03 21:41:06 -04:00
|
|
|
|
2011-08-03 21:44:29 -04:00
|
|
|
if [ "$prev" = "set-default" ]; then
|
2011-08-03 22:43:40 -04:00
|
|
|
_rbenv_versions
|
2011-08-03 21:44:29 -04:00
|
|
|
else
|
2011-08-03 22:43:40 -04:00
|
|
|
_rbenv_commands
|
2011-08-03 21:44:29 -04:00
|
|
|
fi
|
2011-08-03 21:41:06 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
complete -F _rbenv rbenv
|