DocsAutocompleteSchemasSuggestion

Fig takes the user's input, maps it to your completion spec, then uses the completion spec to output an array of suggestion objects. Each item you see in the autocomplete menu below (with an icon, name, and description) is a suggestion object. You can customize a suggestion object to change its UI and the value that's inserted into the terminal when the user presses enter/tab.

You will almost never make Suggestion Objects. Instead, you will make a completion spec of Subcommand, Option, and Arg Objects. Fig will then use these objects to generate Suggestion Objects.

Properties

name

Type: SingleOrArray\<string>

Required:

Description:

The text that’s rendered in each row of Fig's popup. displayName will override this. he name props of suggestion, subcommand, options, and args objects are all different. It's important to read them all carefully.


displayName

Type: string

Required:

Description:

The string that is displayed in the UI for a given suggestion. This Overrides the name property.

Example:

For the npm CLI we have a subcommand called install. If we wanted to display some custom text like Install an NPM package 📦 we would set name: "install" and displayName: "Install an NPM package 📦"


insertValue

Type: string

Required:

Description:

The value that's inserted into the terminal when a user presses enter/tab or clicks on a menu item. You can optionally specify {cursor} in the string and Fig will automatically place the cursor there after insert. The default is the name prop.

Example:

For git commit the -m option has an insert value of -m '{cursor}'


description

Type: string

Required:

Description:

The text that gets rendered at the bottom of the autocomplete box. Keep it short and simple!


icon

Type: string

Required:

Description:

The icon that is rendered is based on the type, unless overwritten. Icon can be a 1 character string, a URL, or Fig's icon protocol (fig://) which lets you generate colorful and fun systems icons: https://fig.io/docs/reference/suggestion/icon-api

Example:

A, 😊 https://www.herokucdn.com/favicon.ico fig://icon?type=file


isDangerous

Type: boolean

Required:

Description:

Specifies whether the suggestion is "dangerous". If so, Fig will not enable its "insert and run" functionality (when Fig has the red insert icon). This will make it harder for a user to accidentally run a dangerous command.

Remark:

This is used in specs like rm and trash.


priority

Type: number

Required:

Description:

The priority for a given suggestion determines its ranking in the Fig popup. A higher ranked priority will be listed first. The min priority is 0. The max priority is 100. The default priority is 50. If a given suggestion has a priority between 50 and 75 (inluding the default 50) AND has been selected by the user before, the prioritiy will be replaced with 75 + the timestamp of when that suggestion was selected as a decimal. If a given suggestion has a priority outside of 50-75 AND has been selected by the user before, the prioritiy will be increased by the timestamp of when that suggestion was selected as a decimal.

Examples:

If you want your suggestions to always be at the top order regardless of whether they have been selected before or not, rank them 76 or above If you want your suggestions to always be at the bottom regardless of whether they have been selected before or not, rank them 49 or below


hidden

Type: boolean

Required:

Description:

Specifies whether a suggestion should be hidden from results. Fig will only show it if the user types the exact same thing as the name

Example:

The "-" suggestion is hidden in the cd spec. You will only see it if you type cd -


type

Type: SuggestionType

Required:

Description:

The type of suggestion, one of folder, file, arg, subcommand, option, special.

On this page