From b4f8906b246711db4c5116a12b6d9b0772084b97 Mon Sep 17 00:00:00 2001 From: Sam Stephenson Date: Tue, 13 Sep 2011 13:12:04 -0500 Subject: [PATCH] Update zsh completion adapter --- completions/rbenv.zsh | 24 ++++++++++-------------- libexec/rbenv-commands | 3 ++- libexec/rbenv-local | 3 ++- libexec/rbenv-sh-shell | 3 ++- 4 files changed, 16 insertions(+), 17 deletions(-) diff --git a/completions/rbenv.zsh b/completions/rbenv.zsh index 45f556e9..f1a41ad9 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 a5d56cc2..297f8d99 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 5e154069..9b102c5c 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 674a9267..a216cb29 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