Skip to content

Commit 5870d4f

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 5870d4f

2 files changed

Lines changed: 84 additions & 7 deletions

File tree

README.md

Lines changed: 52 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,56 @@ 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+
Generate a `_qn` script into a directory on your `$fpath`:
269+
270+
```sh
271+
qn completions zsh > ~/.zfunc/_qn
272+
```
273+
274+
Ensure your `~/.zshrc` has that directory on `$fpath` before `compinit` runs:
275+
276+
```sh
277+
fpath=(~/.zfunc $fpath)
278+
autoload -U compinit
279+
compinit
280+
```
281+
282+
See the [zsh completion-system manual](https://zsh.sourceforge.io/Doc/Release/Completion-System.html) for details.
283+
284+
### fish
250285

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

258304
## Configuration via environment

src/cli.rs

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,38 @@ 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+
Generate a `_qn` completion script and put it somewhere in your `$fpath`:\n\n \
164+
qn completions zsh > ~/.zfunc/_qn\n\n \
165+
Ensure that the following is present in your `~/.zshrc`, with the\n \
166+
directory above on your `$fpath`:\n\n \
167+
fpath=(~/.zfunc $fpath)\n \
168+
autoload -U compinit\n \
169+
compinit\n\n \
170+
See the zsh manual for details:\n \
171+
https://zsh.sourceforge.io/Doc/Release/Completion-System.html\n\n\
172+
### fish\n\n \
173+
Generate a `qn.fish` completion script:\n\n \
174+
qn completions fish > ~/.config/fish/completions/qn.fish\n\n\
175+
### PowerShell\n\n \
176+
Add the following line to your profile script (`$PROFILE`):\n\n \
177+
qn completions powershell | Out-String | Invoke-Expression\n\n \
178+
Or append the generated script so it loads each session:\n\n \
179+
qn completions powershell >> $PROFILE")]
149180
Completions {
150181
/// Shell to generate completions for.
151182
#[arg(value_enum)]

0 commit comments

Comments
 (0)