Skip to main content
Every incur CLI has a built-in completions command that generates shell hook scripts for tab completion. The hook calls back into your binary at every tab press, so completions are always in sync with your commands.

Installation

Generate and install completions for your shell:

Bash

Add to ~/.bashrc for persistence:

Zsh

Add to ~/.zshrc for persistence:

Fish

Add to ~/.config/fish/config.fish for persistence:

Nushell

Add to your nushell config and register as an external completer.

How It Works

Completions are dynamic—the hook calls back into your CLI at every tab press:
This means:
  • Completions are always accurate
  • No generated files to maintain
  • Subcommands, options, and enum values are suggested automatically
  • Works with mounted CLIs and OpenAPI-generated commands

Command Completions

Tab completion suggests available commands:

Subcommand Completions

Command groups suppress trailing space so you can keep tabbing:

Option Completions

Options are suggested when the current word starts with -:
Short aliases are automatically suggested.

Enum Value Completions

Enum options suggest their valid values:

Boolean Options

Boolean options don’t expect values, so completion continues:

Descriptions in Completions

Descriptions from schemas appear in completions:
In zsh and fish, descriptions appear alongside completions:

Multi-Command CLI

Completions work with complex command structures:

Completion Help

Run completions --help for setup instructions:
Output

Implementation

Completions are handled automatically. No additional code needed:
This CLI automatically supports:
  • my-cli completions bash
  • my-cli completions zsh
  • my-cli completions fish
  • my-cli completions nushell

Source Code

The completions implementation is in src/Completions.ts:

Register Hook

Complete Function

Environment Variables

Completions use these environment variables:
VariableDescription
COMPLETEShell type: bash, zsh, fish, nushell
_COMPLETE_INDEXIndex of the word being completed
The shell hook sets these when invoking the CLI.

Debugging Completions

Test completions manually:
This simulates what the shell does when you press tab.

Multiple Binaries

If your CLI has multiple binary names (aliases in package.json), completions work for all of them:

Advanced: Custom Completions

For advanced use cases, you can use the completions API directly:
Completions are dynamic and always in sync with your commands. Just install once per shell and they’ll work forever.