rbenv/completions/rbenv.bash

37 lines
751 B
Bash
Raw Normal View History

2011-08-04 04:43:40 +02:00
_rbenv_commands() {
2011-08-04 03:44:29 +02:00
local cur commands
COMPREPLY=()
cur="${COMP_WORDS[COMP_CWORD]}"
commands="exec prefix rehash set-default set-local version versions\
whence which"
2011-08-04 03:44:29 +02:00
COMPREPLY=( $( compgen -W "$commands" -- $cur ) )
}
2011-08-04 04:43:40 +02:00
_rbenv_versions() {
local cur versions
2011-08-04 03:44:29 +02:00
local ROOT="${HOME}/.rbenv/versions"
COMPREPLY=()
cur=${COMP_WORDS[COMP_CWORD]}
2011-08-04 04:43:40 +02:00
versions=($ROOT/*)
2011-08-04 03:44:29 +02:00
# remove all but the final part of the name
2011-08-04 04:43:40 +02:00
versions="${versions[@]##*/}"
2011-08-04 04:43:40 +02:00
COMPREPLY=( $( compgen -W "$versions" -- $cur ) )
}
2011-08-04 03:44:29 +02:00
_rbenv() {
local cur prev
COMPREPLY=()
cur="${COMP_WORDS[COMP_CWORD]}"
prev="${COMP_WORDS[COMP_CWORD-1]}"
2011-08-04 03:44:29 +02:00
if [ "$prev" = "set-default" ]; then
2011-08-04 04:43:40 +02:00
_rbenv_versions
2011-08-04 03:44:29 +02:00
else
2011-08-04 04:43:40 +02:00
_rbenv_commands
2011-08-04 03:44:29 +02:00
fi
}
complete -F _rbenv rbenv