Skip to content

Commit 572db0d

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 572db0d

2 files changed

Lines changed: 46 additions & 6 deletions

File tree

README.md

Lines changed: 24 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 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,16 +249,30 @@ qn team list
245249

246250
## Shell completions
247251

248-
Homebrew installs completions automatically (see above). For other install
249-
methods, generate them yourself:
252+
Some installs place the completion file for you — Homebrew (see above) and
253+
distro packages drop it in the shell's standard directory. Other install methods
254+
(`cargo install`, a downloaded binary or tarball, Scoop) do not, so generate the
255+
script yourself and write it where your shell loads completions from:
250256

251257
```sh
252-
qn completions zsh > ~/.zfunc/_qn # zsh
253-
qn completions bash > /etc/bash_completion.d/qn # bash
258+
# zsh — write into a dir on your $fpath, then run compinit
259+
mkdir -p ~/.zfunc
260+
qn completions zsh > ~/.zfunc/_qn
261+
262+
# bash — source it from ~/.bashrc (needs bash-completion)
263+
echo 'source <(qn completions bash)' >> ~/.bashrc
264+
265+
# fish — write into fish's completions dir
254266
qn completions fish > ~/.config/fish/completions/qn.fish
255-
qn completions powershell > qn.ps1
267+
268+
# powershell — add to your $PROFILE
269+
qn completions powershell | Out-String | Invoke-Expression
256270
```
257271

272+
For zsh, the completion file's directory must be on `$fpath` before `compinit`
273+
runs — see the
274+
[zsh completion-system manual](https://zsh.sourceforge.io/Doc/Release/Completion-System.html).
275+
258276
## Configuration via environment
259277

260278
The conventional variables are honored: `NO_COLOR` and `TERM=dumb` disable color,

src/cli.rs

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,28 @@ pub enum Command {
146146
Kv(commands::kv::Args),
147147

148148
/// Generate shell completions.
149+
///
150+
/// Some installs place the completion file for you (Homebrew and distro
151+
/// packages drop it in the shell's standard directory); others
152+
/// (`cargo install`, a downloaded binary or tarball, Scoop) do not — for
153+
/// those, generate the script with this command and write it where your
154+
/// shell loads completions from (see the examples below).
155+
///
156+
/// zsh has one extra requirement even once the file is installed: it only
157+
/// autoloads a completion when that file's directory is on `$fpath` before
158+
/// `compinit` runs during shell startup. If `qn <TAB>` falls back to
159+
/// listing files, that directory is missing from `$fpath`. See the zsh
160+
/// manual: https://zsh.sourceforge.io/Doc/Release/Completion-System.html
161+
#[command(after_help = "Examples:\n \
162+
# zsh — write into a dir on your $fpath, then run compinit (see above)\n \
163+
mkdir -p ~/.zfunc\n \
164+
qn completions zsh > ~/.zfunc/_qn\n\n \
165+
# bash — source it from ~/.bashrc (needs bash-completion)\n \
166+
echo 'source <(qn completions bash)' >> ~/.bashrc\n\n \
167+
# fish — write into fish's completions dir (loaded on next shell)\n \
168+
qn completions fish > ~/.config/fish/completions/qn.fish\n\n \
169+
# powershell — add to your $PROFILE\n \
170+
qn completions powershell | Out-String | Invoke-Expression")]
149171
Completions {
150172
/// Shell to generate completions for.
151173
#[arg(value_enum)]

0 commit comments

Comments
 (0)