diff --git a/completions/rbenv.zsh b/completions/rbenv.zsh index 45f556e..f1a41ad 100644 --- a/completions/rbenv.zsh +++ b/completions/rbenv.zsh @@ -1,19 +1,15 @@ compctl -K _rbenv rbenv -function _rbenv_commands() { - local cmds_str="$(rbenv commands)" - reply=("${(ps:\n:)cmds_str}") -} - -_rbenv_versions() { - local versions_str="$(rbenv versions --bare)" - reply=(system "${(ps:\n:)versions_str}") -} - _rbenv() { + local word words completions read -cA words - case "$words[2]" in - set-* | global | local | shell | prefix ) _rbenv_versions ;; - * ) _rbenv_commands ;; - esac + word="${words[2]}" + + if [ "${#words}" -eq 2 ]; then + completions="$(rbenv commands)" + else + completions="$(rbenv completions "${word}")" + fi + + reply=("${(ps:\n:)completions}") } diff --git a/libexec/rbenv-commands b/libexec/rbenv-commands index a5d56cc..297f8d9 100755 --- a/libexec/rbenv-commands +++ b/libexec/rbenv-commands @@ -4,7 +4,8 @@ set -e # Provide rbenv completions if [ "$1" = "--complete" ]; then - echo --sh --no-sh + echo --sh + echo --no-sh exit fi diff --git a/libexec/rbenv-local b/libexec/rbenv-local index 5e15406..9b102c5 100755 --- a/libexec/rbenv-local +++ b/libexec/rbenv-local @@ -4,7 +4,8 @@ set -e # Provide rbenv completions if [ "$1" = "--complete" ]; then - echo system --unset + echo --unset + echo system exec rbenv-versions --bare fi diff --git a/libexec/rbenv-sh-shell b/libexec/rbenv-sh-shell index 674a926..a216cb2 100755 --- a/libexec/rbenv-sh-shell +++ b/libexec/rbenv-sh-shell @@ -4,7 +4,8 @@ set -e # Provide rbenv completions if [ "$1" = "--complete" ]; then - echo system --unset + echo --unset + echo system exec rbenv-versions --bare fi