pyenv/completions/rbenv.bash

37 lines
751 B
Bash
Raw Normal View History

2011-08-03 21:43:40 -05:00
_rbenv_commands() {
2011-08-03 20:44:29 -05: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 20:44:29 -05:00
COMPREPLY=( $( compgen -W "$commands" -- $cur ) )
}
2011-08-03 21:43:40 -05:00
_rbenv_versions() {
local cur versions
2011-08-03 20:44:29 -05:00
local ROOT="${HOME}/.rbenv/versions"
COMPREPLY=()
cur=${COMP_WORDS[COMP_CWORD]}
2011-08-03 21:43:40 -05:00
versions=($ROOT/*)
2011-08-03 20:44:29 -05:00
# remove all but the final part of the name
2011-08-03 21:43:40 -05:00
versions="${versions[@]##*/}"
2011-08-03 21:43:40 -05:00
COMPREPLY=( $( compgen -W "$versions" -- $cur ) )
}
2011-08-03 20:44:29 -05:00
_rbenv() {
local cur prev
COMPREPLY=()
cur="${COMP_WORDS[COMP_CWORD]}"
prev="${COMP_WORDS[COMP_CWORD-1]}"
2011-08-03 20:44:29 -05:00
if [ "$prev" = "set-default" ]; then
2011-08-03 21:43:40 -05:00
_rbenv_versions
2011-08-03 20:44:29 -05:00
else
2011-08-03 21:43:40 -05:00
_rbenv_commands
2011-08-03 20:44:29 -05:00
fi
}
complete -F _rbenv rbenv