Autocomplete prompt for inquirer
Last updated 3 months ago by pn9873 .
ISC · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install autocompleteprompt 
SYNC missed versions from official npm registry.


Autocomplete prompt for inquirer


npm install --save autocompleteprompt


This prompt is anonymous, meaning you can register this prompt with the type name you please:

inquirer.registerPrompt('autocomplete', require('autocompleteprompt'));
  type: 'autocomplete',

Change autocomplete to whatever you might prefer.


Note: allowed options written inside square brackets ([]) are optional. Others are required.

type, name, message, source[, pageSize, filter, when, suggestOnly, validate]

See inquirer readme for meaning of all except source and suggestOnly.

Source will be called with previous answers object and the current user input each time the user types, it must return a promise.

Source will be called once at at first before the user types anything with undefined as the value. If a new search is triggered by user input it maintains the correct order, meaning that if the first call completes after the second starts, the results of the first call are never displayed.

suggestOnly is default false. Setting it to true turns the input into a normal text input. Meaning that pressing enter selects whatever value you currently have. And pressing tab autocompletes the currently selected value in the list. This way you can accept manual input instead of forcing a selection from the list.

validate is only active when suggestOnly is set to true. It behaves like validate for the input prompt.


inquirer.registerPrompt('autocomplete', require('autocompleteprompt'));
  type: 'autocomplete',
  name: 'from',
  message: 'Select a state to travel from',
  source: function(answersSoFar, input) {
    return myApi.searchStates(input);
}]).then(function(answers) {

I recommend using this package with fuzzy if you want fuzzy search. Again, see the example for a demonstration of this.

Changes to Original

Inquerer version issue due to which the prefix was not passed on. Prompt select icon changed to unicode.


Martin Hansen



Current Tags

  • 1.2.1                                ...           latest (3 months ago)

1 Versions

  • 1.2.1                                ...           3 months ago
Maintainers (1)
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 1
Dependencies (4)
Dev Dependencies (0)
Dependents (0)

Copyright 2014 - 2016 © |