From 0f1294812d37e325c4a51509bde9edba37c52fc8 Mon Sep 17 00:00:00 2001 From: Masafumi Koba <473530+ybiquitous@users.noreply.github.com> Date: Mon, 6 Jan 2025 10:39:05 +0900 Subject: [PATCH] feat(rbenv): provide completion for `rbenv` command Ref https://github.com/rbenv/rbenv/#shell-completions --- plugins/rbenv/README.md | 2 ++ plugins/rbenv/rbenv.plugin.zsh | 6 ++++++ 2 files changed, 8 insertions(+) diff --git a/plugins/rbenv/README.md b/plugins/rbenv/README.md index 43a2e93ac..720730337 100644 --- a/plugins/rbenv/README.md +++ b/plugins/rbenv/README.md @@ -3,6 +3,8 @@ The primary job of this plugin is to provide `rbenv_prompt_info` which can be added to your theme to include Ruby version and gemset information into your prompt. +Additionally, this plugin provides completion for the `rbenv` command. See also . + Some functionality of this plugin will not work unless you also have the rbenv plugin *gemset* installed. https://github.com/jf/rbenv-gemset diff --git a/plugins/rbenv/rbenv.plugin.zsh b/plugins/rbenv/rbenv.plugin.zsh index d758aebae..4f8b022af 100644 --- a/plugins/rbenv/rbenv.plugin.zsh +++ b/plugins/rbenv/rbenv.plugin.zsh @@ -2,6 +2,7 @@ # the 'rbenv_prompt_info' function. FOUND_RBENV=$+commands[rbenv] +RBENV_ROOT='' if [[ $FOUND_RBENV -ne 1 ]]; then rbenvdirs=("$HOME/.rbenv" "/usr/local/rbenv" "/opt/rbenv" "/usr/local/opt/rbenv") @@ -9,6 +10,7 @@ if [[ $FOUND_RBENV -ne 1 ]]; then if [[ -d $dir/bin ]]; then export PATH="$dir/bin:$PATH" FOUND_RBENV=1 + RBENV_ROOT="$dir" break fi done @@ -24,6 +26,10 @@ if [[ $FOUND_RBENV -ne 1 ]]; then fi if [[ $FOUND_RBENV -eq 1 ]]; then + if [[ -d "$RBENV_ROOT/completions" ]]; then + fpath+=("$RBENV_ROOT/completions") + fi + eval "$(rbenv init --no-rehash - zsh)" alias rubies="rbenv versions"