DocsPrivate autocomplete

Build Autocomplete for Private CLIs, Scripts, and Shortcuts

Fig makes it easy to build autocomplete for your private CLIs, scripts, and shortcuts.

This guide walks you through how to set up Fig's pre-built environment that makes it easy to create, test, and share your autocomplete specs.

Note: If you want to build and contribute to specs for public CLI tools (like git, docker, npm...) view our Getting Started guide

Init the .fig folder

Go to the directory that contains your CLI or script and run the following:

npx @withfig/autocomplete-tools@latest init

This will create initialize a .fig/ folder in your current working directory with the following structure:

my_cli/                         # directory containing your script / CLI 
├── .fig/
│   ├── autocomplete/
│   │   ├── src/                # where you edit your completion specs
│   │   ├── build/              # where your specs compile to
│   │   ├── package.json
│   └── user/
│       └── autocomplete/
│           ├── src/            # where you edit your mixins
│           ├── build/          # where your mixins compile to
│           ├── package.json
├── my_cli.sh                   # your script or CLI tool

This is like a minimal version of the withfig/autocomplete repo with an empty src folder and all the tooling you need to build specs.

Create, test, and compile specs

Both the .fig/autocomplete/ and .fig/user/autocomplete/ folder contain a package.json with the following scripts:

# Make a new typescript completion spec in src/ 
npm run create-spec <spec_name>

# Start dev mode to see live updates to your spec in your terminal as you edit.
npm run dev

# Compile your specs from the src/ folder to build/ folder (dev mode does this automatically)
npm run build

That's it!

Now what?

Use this environment to build autocomplete for your

Team's Internal CLI tool

Local Scripts

Personal Shortcuts

Mixins