Skip to content

joona/node-fzf

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

21 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

npm npm

node-fzf

fzf inspired fuzzy CLI list selection 🎀

Easy to use

CLI usage

npm install -g node-fzf

# by default (TTY mode) will glob list of current dir files
nfzf

# using pipes
find . | grep -v node_modules | nfzf

API usage

const nfzf = require( 'node-fzf' )

const list = [ 'whale', 'giraffe', 'monkey' ]

// opens interactive selection CLI
// note! this messes with stdout so if you are
// writing to stdout at the same time it will look a bit messy..
const api = nfzf( list, function ( value, index ) {
  console.log( value ) // 'giraffe'
  console.log( index ) // 1
  console.log( value === list[ index ] ) // true
} )

// can also add more items later..
setInterval( function () {
  list.push( 'foobar' )
  api.update( list )
}, 1000 )

Keyboard

<ctrl-j>,down                 scroll down
<ctrl-k>,up                   scroll up

<ctrl-d>                      scroll down by 10
<ctrl-u>                      scroll up by 10

<esc>,<ctrl-q>,<ctrl-c>       cancel

<return>,<ctrl-m>             trigger callback with current selection and exit

<ctrl-w>                      clear current fuzzy search

<backspace>                   delete last fuzzy search character

About

fzf inspired fuzzy CLI list selection thing for node.

Why

easy fuzzy list selection UI for NodeJS CLI programs.

How

Mostly cli-color for dealing with the terminal rendering and ttys to hack the ttys to simultaneously read from non TTY stdin and read key inputs from TTY stdin -> So that we can get piped input while also at the same time receive and handle raw keyboard input.

Used by

yt-play

yt-search

Alternatives

fzf even though it doesn't work in NodeJS directly is all-in-all a better tool than this piece of crap :) Highly recommend~

Test

No tests..

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • JavaScript 100.0%