Skip to content

Commit 0da2f05

Browse files
DeflaimunFeediver1
andauthored
change fpath instructions to be more broad (#936)
Co-authored-by: Joyce Fee <[email protected]>
1 parent 5f1ad50 commit 0da2f05

File tree

1 file changed

+22
-10
lines changed

1 file changed

+22
-10
lines changed

modules/reference/pages/rpk/rpk-generate/rpk-generate-shell-completion.adoc

Lines changed: 22 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -34,26 +34,38 @@ rpk generate shell-completion bash > /etc/bash_completion.d/rpk
3434

3535
== Zsh
3636

37-
To enable autocompletion in any zsh session for any user, run this once:
37+
To enable autocompletion in any zsh session for any user, follow these steps:
3838

39-
[,bash]
39+
Determine which directory in your `$fpath` to use to store the completion file.
40+
41+
You can inspect your `fpath` by running:
42+
[,zsh]
4043
----
41-
rpk generate shell-completion zsh > "${fpath[1]}/_rpk"
44+
echo $fpath
4245
----
4346

44-
You can also place that command in your `~/.zshrc` to ensure that when you update
45-
`rpk`, you update autocompletion. If you initially require `sudo` to edit that
46-
file, you can `chmod` it to be world writeable, after which you will always be
47-
able to update it from `~/.zshrc`.
47+
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:
4848

49-
If shell completion is not already enabled in your zsh environment, also
50-
add the following to your `~/.zshrc`:
49+
[,zsh]
50+
----
51+
rpk generate shell-completion zsh > /usr/local/share/zsh/site-functions/_rpk
52+
----
5153

54+
If the directory you chose is not already in `fpath`, add it to your `.zshrc`:
5255
[,zsh]
5356
----
54-
autoload -U compinit; compinit
57+
fpath+=(/usr/local/share/zsh/site-functions)
5558
----
5659

60+
Finally, ensure that `compinit` is run. Add (or verify) the following in your `.zshrc`:
61+
62+
[,zsh]
63+
----
64+
autoload -U compinit && compinit
65+
----
66+
67+
After restarting your shell, `rpk` completion should be active.
68+
5769
== Fish
5870

5971
To enable autocompletion in any `fish` session, run:

0 commit comments

Comments
 (0)