From 0da2f053af28c7e905947ba917eb76a12470cfcf Mon Sep 17 00:00:00 2001 From: Paulo Borges Date: Fri, 20 Dec 2024 18:40:38 -0300 Subject: [PATCH] change fpath instructions to be more broad (#936) Co-authored-by: Joyce Fee <102751339+Feediver1@users.noreply.github.com> --- .../rpk-generate-shell-completion.adoc | 32 +++++++++++++------ 1 file changed, 22 insertions(+), 10 deletions(-) diff --git a/modules/reference/pages/rpk/rpk-generate/rpk-generate-shell-completion.adoc b/modules/reference/pages/rpk/rpk-generate/rpk-generate-shell-completion.adoc index 63a373a46..987b3a52e 100644 --- a/modules/reference/pages/rpk/rpk-generate/rpk-generate-shell-completion.adoc +++ b/modules/reference/pages/rpk/rpk-generate/rpk-generate-shell-completion.adoc @@ -34,26 +34,38 @@ rpk generate shell-completion bash > /etc/bash_completion.d/rpk == Zsh -To enable autocompletion in any zsh session for any user, run this once: +To enable autocompletion in any zsh session for any user, follow these steps: -[,bash] +Determine which directory in your `$fpath` to use to store the completion file. + +You can inspect your `fpath` by running: +[,zsh] ---- -rpk generate shell-completion zsh > "${fpath[1]}/_rpk" +echo $fpath ---- -You can also place that command in your `~/.zshrc` to ensure that when you update -`rpk`, you update autocompletion. If you initially require `sudo` to edit that -file, you can `chmod` it to be world writeable, after which you will always be -able to update it from `~/.zshrc`. +Choose one of the directories listed. For example, if `/usr/local/share/zsh/site-functions` is present in your `fpath`, you can place the `_rpk` completion file there: -If shell completion is not already enabled in your zsh environment, also -add the following to your `~/.zshrc`: +[,zsh] +---- +rpk generate shell-completion zsh > /usr/local/share/zsh/site-functions/_rpk +---- +If the directory you chose is not already in `fpath`, add it to your `.zshrc`: [,zsh] ---- -autoload -U compinit; compinit +fpath+=(/usr/local/share/zsh/site-functions) ---- +Finally, ensure that `compinit` is run. Add (or verify) the following in your `.zshrc`: + +[,zsh] +---- +autoload -U compinit && compinit +---- + +After restarting your shell, `rpk` completion should be active. + == Fish To enable autocompletion in any `fish` session, run: