# runtime completion resolution the `complete` command has built-in on-the-fly resolution: when a command is not found in the index, it falls back to running `--help`, caches the result, and returns completions immediately. this means commands installed outside the system profile (via cargo, pip, npm, go, etc.) get completions on first tab-press with no manual setup. ## how it works when you type `docker compose up --`: 1. nushell calls `inshellah complete docker compose up --` 2. inshellah looks up the index for the longest matching prefix 3. if found, it fuzzy-matches flags and subcommands against the partial input 4. if not found, it locates the binary in `$PATH`, runs `--help`, recursively resolves subcommands, caches the results in the user directory (`$XDG_CACHE_HOME/inshellah`), and returns completions all subsequent completions for that command are instant (served from cache). ## setup the completer works with no extra configuration beyond the basic setup: ```nu # ~/.config/nushell/config.nu $env.config.completions.external = { enable: true completer: {|spans| inshellah complete ...$spans | from json } } ``` with the nixos module, add `--system-dir` to also search the system index: ```nu $env.config.completions.external = { enable: true completer: {|spans| inshellah complete ...$spans --system-dir /run/current-system/sw/share/inshellah | from json } } ``` or use the `snippet` option provided by the flake module (see [nixos.md](nixos.md)). ## cache management the user cache lives at `$XDG_CACHE_HOME/inshellah` (typically `~/.cache/inshellah`). ```sh # list cached commands inshellah dump # view cached data for a command inshellah query docker # clear cache rm -rf ~/.cache/inshellah/ # re-index from a prefix inshellah index /usr --dir ~/.cache/inshellah ``` ## when to use this vs build-time indexing the nixos module (`programs.inshellah.enable = true`) handles system packages at build time. runtime resolution covers: - commands installed outside the system profile (cargo, pip, npm, go) - subcommand completions at arbitrary depth - systems without the nixos module for upfront indexing on non-nixos systems: ```sh inshellah index /usr /usr/local ```