Skip to content

saehun/node-peco

Folders and files

NameName
Last commit message
Last commit date
Oct 11, 2020
Oct 10, 2020
Apr 4, 2021
Oct 11, 2020
Sep 25, 2020
Oct 11, 2020
Oct 10, 2020
Sep 25, 2020
Apr 4, 2021
Sep 25, 2020
Apr 4, 2021
Oct 10, 2020
Jun 25, 2021

Repository files navigation

Node Peco

peco nodejs binding library

NOTE: external command peco is required. see peco installation

NPM github ci npm npm bundle size

example

Installation

yarn add node-peco

Usage

This package exports only one function named peco.

import { peco } from 'node-peco'; // or require('node-peco');

peco(['foo', 'bar', 'baz']).then(selected => console.log(selected));

You can pass option as a second argument

import { peco, PecoOption } from 'node-peco';

const pecoOption: PecoOption = {
  onCancel: 'reject',
  layout: 'bottom-up',
  selectionPrefix: '*',
  prompt: "Choose ->",
};

peco(['foo', 'bar', 'baz'], pecoOption).then(selected => console.log(selected));

for more examples, see examples

Option

There are two categories of option. One is js dependent:

key type description default
bin string peco binary command(or location path) "peco"
onCancel "reject" | "skip" specify behavior when received SIGINT "skip"
onError "reject" | "exit" specify behavior when peco exited with non-zero code "exit"

The other is peco command line option. See peco#command-line-options