• Stars
    star
    843
  • Rank 53,815 (Top 2 %)
  • Language
    JavaScript
  • License
    MIT License
  • Created over 8 years ago
  • Updated over 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Interactive Pipe To: The Node.js cli interactive workflow



ipt logo


iPipeTo

NPM version Build Status License Join the chat at https://gitter.im/ipipeto/Lobby

Interactive Pipe To: The Node.js cli interactive workflow


Table of Contents


About

ipt (pronounced iPipeTo) introduces the missing cli interactive workflow. It takes any kind of list as an input and uses that list to build an interactive interface to let you select an element from it.

Stop manually dragging your mouse around to copy output data from a terminal, using the ipt workflow you can pipe data from a command and select what to copy to clipboard from a convenient visual menu.

Selected data is also output to stdout allowing for easily composing various workflows - Just create your custom alias!



demo animation


πŸ“° News

  • v3.2.0:
    • Added -i option for arbitrary input prompts
  • v3.1.0:
    • Added -o option for ordered multiple choice selection
  • v2.1.0:
    • Added -D option for defining a pre-selected item in the list
  • v2.0.0:
    • Added -p option for extracting path out of selected items
    • Added -M option for customizing interface message
    • Added -0 option for better null char compatibility
    • Added -S option for setting number of lines to be displayed
    • Added a proper programmatic API
  • v1.1.0: Added autocomplete (or fuzzy finder) mode ipt -a

😍 Features

Reads from standard input, prints to standard output

iPipeTo is inspired by the Unix Pipeline and is composable with any command line utility you already use and love.

Select multiple items

The -m or --multiple flag allows you to select many items out of the interactive list instead of the standard "pick one" behavior.

Fuzzysearch (autocomplete mode)

Using -a or --autocomplete option switchs the behavior of the interactive list to that of a fuzzysearch (or autocomplete) where options are narrowed as you type.

Extract path from result

A convenient option that helps extract file system path values out of the selected item, very useful when manipulating verbose output. Use -p or --extract-path options.

Input prompt

Use the -i or --input option in order to use ipt as a simple input prompt, default values can be set using standard input or the --default argument.

Copy to clipboard

The -c or --copy option allows you to copy the selected item value to clipboard. Makes for useful workflows where you may need that value somewhere else such as out of the terminal or in a manual command to type later.

Customization

Customize your workflow by defining the separator to be used to generate the list (-s or --separator options), a custom message to display on the interactive interface (-M or --message) and much more. Make sure to take a look at the Help section to learn about all the available options.

Default selected items

Use the -D or --default option to determine which item(s) should be selected by default on the interactive list. The -P or --default-separator also allows for a custom char to be used to split these items (similar to -s option).

Node.js based

All you need in order to run ipt is the Node.js runtime and npm, if you have those you're already all set!


πŸ”Ž Examples

The default behavior of ipt is to allow for the selection of one item from the interactive list, once selected this item will be output to stdout, you can also use -c option to copy the result to your clipboard.

Using Unix pipes to send selected value to next command

Here we get a simple list of branchs git branch -a, pipe into ipt and pipe the selected item value to git checkout to checkout into the selected branch. xargs is needed to get the data from standard input and read it as an argument.


`git branch -a | ipt | xargs git checkout` selects a branch name from menu and that branch gets checked out by git



Using the multiple choices option

In the following example we list all the files from the folder ls and pipe that list into ipt only that this time we use the "multiple" flag -m that allows for selecting multiple items from a list. The selected items get piped to trash that deletes them.


`ls | ipt -m | xargs rm` selects multiple items from the menu and deletes them



NOTE: An ordered multiple choice menu is available when using the -o OR --ordered option

Using file as input data

You can also read a file as source of input data instead of reading from the standard input, here we read from a TODO file and redirect the selected items to be written in a DONE file.


Selects multiple lines from a file and append them to another one



⬇️ Install

Available on npm:

npm install -g ipt

Keep in mind that you'll need the latest Node.js LTS installed!


πŸŒ… Awesome workflows

Showcases some useful predefined workflow scripts for using iPipeTo:

  • ntl: Interactive cli menu to list/run npm tasks
  • itrash: Selects files to delete from current folder
  • git-iadd: Interactive staging of selected changed files
  • git-ishow: Choose one git stash item to show
  • npmlist: Fuzzy list everything with npm module

Found an awesome workflow idea? Send us a PR to add it here!


Help

Usage:
  ipt [options] [<path>]

Options:
  -0, --null               Uses a null character as separator          [boolean]
  -a, --autocomplete       Starts in autocomplete mode                 [boolean]
  -c, --copy               Copy selected item(s) to clipboard          [boolean]
  -d, --debug              Prints to stderr any internal error         [boolean]
  -D, --default            Select a default choices by their name       [string]
  -P, --default-separator  Separator element for default items          [string]
  -e, --file-encoding      Encoding for file <path>, defaults to utf8   [string]
  -h, --help               Shows this help message                     [boolean]
  -i, --input              Open an interactive input prompt            [boolean]
  -m, --multiple           Allows the selection of multiple items      [boolean]
  -o, --ordered            Selects multiple items in order             [boolean]
  -M, --message            Replaces interface message                   [string]
  -p, --extract-path       Returns only a valid path for each item     [boolean]
  -s, --separator          Separator to to split input into items       [string]
  -S, --size               Amount of lines to display at once           [number]
  -t, --no-trim            Prevents trimming of the result strings     [boolean]
  -u, --unquoted           Force the output to be unquoted             [boolean]
  -v, --version            Show version number                         [boolean]

Supported OS Terminals

iPipeTo should run just fine in any of the Inquirer.js supported terminals:

  • Mac OS:
    • Terminal.app
    • iTerm
  • Linux (Ubuntu, openSUSE, Arch Linux, etc):
    • gnome-terminal (Terminal GNOME)
    • konsole
  • Windows*:
    • cmd.exe
    • Powershell
    • Cygwin

Contributing

Bug fixes / code changes: Please provide tests covering your changes, update docs accordingly and keep your changes to a single commit.


Alternatives

As in any cool idea, iPipeTo is not the only available choice, here are some other cool similar tools found in the wild:


Roadmap

Are you wondering what can you do or how would you start contributing to iPipeTo's future? Take a look at our Roadmap document to find out about what's planned ahead and what currently needs help.


Credits

  • The iPipeTo logo is a kind contribution from Bruno Magal

License

MIT Β© 2021 Ruy Adorno

More Repositories

1

ntl

Node Task List: Interactive cli to list and run package.json scripts
JavaScript
888
star
2

simple-slider

🎠 The 1kb JavaScript Carousel
JavaScript
601
star
3

snapstub

Copy API endpoints to your fs and run a local server using them
JavaScript
255
star
4

dom-i18n

Provides a very basic HTML multilingual support using JavaScript
JavaScript
139
star
5

grunt-menu

Useful menu interface for listing/executing your configured tasks
JavaScript
79
star
6

installme-osx

My personal script to setup a new OSX
Shell
60
star
7

git-bc

Git plugin to interactively list branches and checkout
JavaScript
60
star
8

generator-umd

An Yeoman Generator to create a basic UMD structure
JavaScript
28
star
9

console-faker

Get some file content to be printed out on console while you type anything on your keyboard.
JavaScript
26
star
10

preact-jest-snapshot-test-boilerplate

πŸš€ Test Preact components using Jest snapshots
JavaScript
23
star
11

mitro-cli

Manage your Mitro passwords from a command line interface.
JavaScript
22
star
12

telegram-pi-bot

A python-telegram-bot setup to run on Raspberry pi
Python
22
star
13

polymer-simple-slider

A Polymer element providing a simple slider functionality
HTML
22
star
14

jest-serializer-html-string

A better Jest snapshot serializer for plain html strings
JavaScript
17
star
15

prettierme

Fastest way to run prettier for a single file. Fork of https://github.com/ruyadorno/eslintme
Shell
15
star
16

angular-simple-slider

An AngularJS directive providing a simple slider functionality
JavaScript
15
star
17

checkbower

Validates your bower.json files
JavaScript
13
star
18

itrash

Interactively selects files to delete from current folder in the cli
JavaScript
13
star
19

git-iadd

Git plugin that allows you to interactively select which files to add to stage (git add)
JavaScript
12
star
20

dotfiles

Shell
11
star
21

mail-sender

A simple python script to send an html email using smtplib
Python
10
star
22

clean-dir

Command line util to clean a directory
JavaScript
9
star
23

request-hash

Generate a hash from an express Request or http.IncomingMessage
JavaScript
8
star
24

path-complete-extname

path.extname implementation adapted to also include multiple dots extensions.
JavaScript
8
star
25

eslintme

The fastest way to eslint a single file
Shell
7
star
26

extract-path

Extract a valid file system path from a string
JavaScript
7
star
27

lru-cache-fs

Extends lru-cache to add file system support
JavaScript
6
star
28

estimate

Application to help time estimation for digital agencies.
Python
5
star
29

js-signals-factory

A small factory implementation for js-signals.
JavaScript
5
star
30

git-pr

Interactive checkout PRs using the GitHub cli
Shell
4
star
31

git-ishow

Git plugin that lets you interactively select a stashed item to show
JavaScript
4
star
32

tlr

Quick spawn a tiny-lr server
JavaScript
4
star
33

nextjs-api-fetch-example

A simple example using fetched API data to render components
JavaScript
4
star
34

simple-output

Output messages to stdout/stderr
JavaScript
4
star
35

extend-grunt-plugin

Helper method to easily extend an already existing grunt task.
JavaScript
4
star
36

create-100-workshop

The road to 100% test coverage workshop
JavaScript
3
star
37

npx-utils

πŸ‘Ύ Manages packages in the npx-space
JavaScript
3
star
38

simple-data-structures

πŸŒ… Basic data structures with tons of tests and helper functions
Python
2
star
39

cli-all-the-things

Talk at ForwardJS 2020
JavaScript
2
star
40

npm-community-landing-page

HTML
2
star
41

outdated

Shortcut to interactively update an outdated dep using npm + ipt
Shell
1
star
42

redact

Small cli util that redacts path refs from stdin
JavaScript
1
star
43

stubborn-server-hash-loader

Loader plugin for stubborn-server
JavaScript
1
star
44

ruyadorno.github.io

HTML
1
star
45

mitro-js

Mirror of the API to access Mitro server side from node applications.
JavaScript
1
star
46

vim-change-indent

Vim plugin to convert the indent sizes in a file.
Vim Script
1
star
47

ruyadorno

1
star
48

generator-jsmontreal

A test generator to be presented at js-montreal 02/10 meetup
JavaScript
1
star
49

checkgituser

Checks a folder to find .git/config files without an [user] field declared
Python
1
star
50

the-one-with-test-coverage

Demo repo for my test coverage talk from JS Montreal 10/2019
JavaScript
1
star