omelette
Omelette is a simple, template based autocompletion tool for Node and Deno projects with super easy API. (For Bash, Zsh and Fish)
A library that adds Tab-key autocompletion to your Node.js or Deno command-line tool, supporting Bash, Zsh, and Fish shells.
Omelette is a library for adding tab-completion to Node.js or Deno command-line tools. Tab-completion is the feature where you press Tab in a terminal and the shell suggests or fills in the next word for you. Adding this to a custom CLI tool normally requires writing shell-specific scripts, but Omelette handles that complexity so you can describe the completions in JavaScript instead.
You define what suggestions to show at each position in the command using a simple template. For example, you can say that after the first argument the user should see a list of actions, and after the second argument they should see a list of usernames read from the file system. Omelette supports Bash, Zsh, and Fish shells.
There are a few styles for defining completions. The simplest is a JavaScript template literal where you write the command name and pass arrays of options inline. A more structured option is the tree API, where you pass a nested object describing all the valid subcommands and their sub-options. For dynamic completions, you can provide functions or async functions that fetch options at the moment the user presses Tab.
Omelette can also install and uninstall the completion setup automatically by writing the necessary lines into the user's shell configuration file. This means your tool can offer a setup command that users run once, after which completions work in every new terminal session.
Where it fits
- Add Tab-key completion to a custom CLI tool without writing shell scripts.
- Show dynamic completion suggestions fetched at the moment the user presses Tab.
- Define subcommands and their options using the structured tree API.
- Let users install completions for your tool with a single setup command.