Skip to content

Commit 0426bc8

Browse files
committed
docs(completions): document zsh fpath requirement for tab-completion (DX-5783)
Brew installs the completion files, but zsh only autoloads a completion when its directory is on $fpath before compinit runs — so `qn <TAB>` still fell back to filename completion for many zsh users. Document the requirement in the README (both completions sections, linking the zsh manual) and make `qn completions --help` self-documenting with a long_about explaining install-path and zsh nuances plus per-shell install examples. No behavior change to the command itself.
1 parent 71cbc4e commit 0426bc8

2 files changed

Lines changed: 86 additions & 7 deletions

File tree

README.md

Lines changed: 53 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,11 @@ brew install quicknode/tap/qn
3838
```
3939

4040
Homebrew installs shell completions automatically — open a new shell after
41-
install (zsh users may need one `compinit` refresh) and `qn <TAB>` works.
41+
install and `qn <TAB>` works. zsh users may have one extra requirement: zsh only
42+
autoloads a completion when its directory is on `$fpath` before `compinit` runs
43+
at shell startup. If `qn <TAB>` lists files instead of subcommands, the Homebrew
44+
completions directory is missing from `$fpath` — see the
45+
[zsh completion-system manual](https://zsh.sourceforge.io/Doc/Release/Completion-System.html).
4246

4347
### Scoop (Windows)
4448

@@ -245,14 +249,57 @@ qn team list
245249

246250
## Shell completions
247251

248-
Homebrew installs completions automatically (see above). For other install
249-
methods, generate them yourself:
252+
When installing qn through a package manager, it's possible that no additional
253+
shell configuration is necessary — Homebrew (see above) and distro packages
254+
place the script for you. To set up completions manually, follow the
255+
instructions below (`qn completions --help` prints the same). Exact config file
256+
locations may vary by system; restart your shell before testing.
257+
258+
### bash
259+
260+
Install `bash-completion` with your package manager, then add to `~/.bashrc`:
261+
262+
```sh
263+
eval "$(qn completions bash)"
264+
```
265+
266+
### zsh
267+
268+
Homebrew already creates this `_qn` file for you on `brew install`. To set it up
269+
manually, generate the script into a directory on your `$fpath` (Apple Silicon
270+
shown; Intel brew uses `/usr/local/share/zsh/site-functions`):
271+
272+
```sh
273+
qn completions zsh > /opt/homebrew/share/zsh/site-functions/_qn
274+
```
275+
276+
Ensure that the following is present in your `~/.zshrc`:
277+
278+
```sh
279+
autoload -U compinit
280+
compinit
281+
```
282+
283+
See the [zsh completion-system manual](https://zsh.sourceforge.io/Doc/Release/Completion-System.html) for details.
284+
285+
### fish
250286

251287
```sh
252-
qn completions zsh > ~/.zfunc/_qn # zsh
253-
qn completions bash > /etc/bash_completion.d/qn # bash
254288
qn completions fish > ~/.config/fish/completions/qn.fish
255-
qn completions powershell > qn.ps1
289+
```
290+
291+
### PowerShell
292+
293+
Add this line to your profile script (`$PROFILE`):
294+
295+
```powershell
296+
qn completions powershell | Out-String | Invoke-Expression
297+
```
298+
299+
Or append the generated script so it loads each session:
300+
301+
```powershell
302+
qn completions powershell >> $PROFILE
256303
```
257304

258305
## Configuration via environment

src/cli.rs

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,39 @@ pub enum Command {
145145
/// Manage the Quicknode KV store (sets and lists).
146146
Kv(commands::kv::Args),
147147

148-
/// Generate shell completions.
148+
/// Generate shell completion scripts.
149+
///
150+
/// When installing qn through a package manager, it's possible that no
151+
/// additional shell configuration is necessary to gain completion support.
152+
/// Homebrew and distro packages place the script for you.
153+
///
154+
/// If you need to set up completions manually, follow the instructions
155+
/// below. The exact config file locations might vary based on your system.
156+
/// Make sure to restart your shell before testing whether completions are
157+
/// working.
158+
#[command(after_long_help = "### bash\n\n \
159+
First, ensure that you install `bash-completion` using your package manager.\n\n \
160+
After, add this to your `~/.bashrc`:\n\n \
161+
eval \"$(qn completions bash)\"\n\n\
162+
### zsh\n\n \
163+
Homebrew already creates this `_qn` file for you on `brew install`. To\n \
164+
set it up manually, generate the script into a directory on your\n \
165+
`$fpath` (Apple Silicon shown; Intel brew uses\n \
166+
`/usr/local/share/zsh/site-functions`):\n\n \
167+
qn completions zsh > /opt/homebrew/share/zsh/site-functions/_qn\n\n \
168+
Ensure that the following is present in your `~/.zshrc`:\n\n \
169+
autoload -U compinit\n \
170+
compinit\n\n \
171+
See the zsh manual for details:\n \
172+
https://zsh.sourceforge.io/Doc/Release/Completion-System.html\n\n\
173+
### fish\n\n \
174+
Generate a `qn.fish` completion script:\n\n \
175+
qn completions fish > ~/.config/fish/completions/qn.fish\n\n\
176+
### PowerShell\n\n \
177+
Add the following line to your profile script (`$PROFILE`):\n\n \
178+
qn completions powershell | Out-String | Invoke-Expression\n\n \
179+
Or append the generated script so it loads each session:\n\n \
180+
qn completions powershell >> $PROFILE")]
149181
Completions {
150182
/// Shell to generate completions for.
151183
#[arg(value_enum)]

0 commit comments

Comments
 (0)