Build autocomplete for your local scripts like
Go to the directory that contains your script and run the following
npx -y @withfig/autocomplete-tools@latest init
This will create initialize a
.fig/ folder in your current working directory like the following
scripts/ ├── .fig/ │ └── autocomplete/ │ ├── src/ # where you edit your completion specs │ ├── build/ # where your specs compile to │ ├── .eslintrc.js │ ├── README.md │ ├── package-lock.json │ ├── package.json │ └── tsconfig.json ├── node_modules/ └── my_script.sh
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.
cd into the
.fig/autocomplete/ folder and run the remaining commands as package.json scripts
# Make a new completion spec in src/. # You must name it the exact same as your script including the extension # e.g. if your script is called "my_script.sh", call your spec "my_script.sh" 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
Now when you type something like
./my_script.sh, Fig will load up the
.fig/autocomplete/my_script.sh.js completion spec automatically. This also works for things like
python deploy.py or
Note: Fig is working on providing a much better experience for building specs for your scripts. In the meantime if you need help, please email firstname.lastname@example.org
Looking to build comprehensive internal CLIs for your team with Fig?
See "Building Autocomplete for teams" for more details.
For more information on building more complex autocomplete specs, see "Dynamic Suggestions".