DocsReferenceSuggestion

Suggestion

Suggestion is a base class that defines the properties which specify how an item will appear and behave in the Fig autocomplete popup.

Every item that appears in the autocomplete popup is backed by a Suggestion object, which defines its icon, name, description and more.

Other types used to construct a completion spec, like Subcommand and Option, are subclasses of Suggestion and inherit its properties. Generators produce a list of 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. The 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:

The npm CLI has 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 use \n to insert a newline or \b to insert a backspace. You can also optionally specify {cursor} in the string and Fig will automatically place the cursor there after insert. The default is the name prop.

Example:

For the git commit subcommand, 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 (or the side if you hit ⌘i)


icon

Type: string

Required:

Description:

The icon that is rendered is based on the type. Icons can be a 1 character string, a URL, or Fig's icon protocol (fig://) which lets you generate colorful and fun systems icons.

Example:

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


isDangerous

Type: boolean

Required:

Description:

Specifies whether the suggestion is "dangerous". If true, 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.

Example:

This is used in the rm spec.


priority

Type: number

Required:

Description:

The priority between 0-100 for a given suggestion determines its ranking in the Fig popup. A higher ranked priority will be listed first. The default priority is 50. If a given suggestion has a priority between 50-75 inclusive AND has been selected by the user before, the priority 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 priority will be increased by the timestamp of when that suggestion was selected as a decimal.

Example:

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 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.