npm

npm’s 2019 JavaScript ecosystem survey analysis is now available!Get your copy here »

ipt

1.0.0 • Public • Published

iPipeTo NPM version Build Status

Interactive Pipe To: The missing cli interactive workflow

demo gif

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!

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 pipes to send selected value to next command

Here we get a simple list of branchs, 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.

 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.

 selects multiple items from the menu and deletes them

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

Using the copy to clipboard feature

In the example below we show a menu containing the local directories. The selected choice gets copy to clipboard and we can reuse the selected value later with ctrl/cmd + V.

 select item from menu and then  followed by


More

We just covered some basic examples here, if you want more advanced uses, check our Gallery below.

iPipeTo is the DIY kit for interactive interfaces in the command-line, plug whatever you want in, do something fun with the output!

Awesome workflow Gallery

Showcases some useful predefined workflow scripts for using iPipeTo:

# irm: Selects files to delete from current folder (recommended to use trash instead of rm -rf) 
alias irm="ls | ipt -m -n | xargs rm -rf"
 
# irebase: Interactive build a list of git commits from log and rebase from selected one 
alias irebase="git --no-pager log --oneline | ipt -n | cut -d ' ' -f 1 | xargs -o git rebase -i"
 
# icheckout: Interactive git checkout a commit, similar to irebase 
alias icheckout="git --no-pager log --oneline | ipt -n | cut -d ' ' -f 1 | xargs git checkout"

Got an awesome alias idea? Send us a PR to add it to our gallery

Beguinners Help

Do you love all these fancy interactions from the examples above but don't quite follow all this unix jargon? Worry not, in the Awesome Gallery just above we have some common workflow scripts pre configured to be used as simple shell commands.

We also provide a simple example of how to get the commands in the Install section below.

Install

Install it easily using npm:

$ npm install -g ipt

Keep in mind that you'll need to have at least Node.js > 0.12 installed

Beguinners Setup

So do you like the previous examples but are not super confident on how to configure these commands? Although I'd really recommend you to take a look at how to do it yourself, below is a quick script for you to run in your terminal and have all of our gallery scripts at once.

OSX

curl -fsSL https://raw.githubusercontent.com/ruyadorno/ipt/master/gallery.sh >> ~/.bash_profile

Unix

curl -fsSL https://raw.githubusercontent.com/ruyadorno/ipt/master/gallery.sh >> ~/.bashrc

Help

Usage:
  ipt [<path>]
 
Specify a file <path> or pipe some data from stdin to start interacting.
 
Options:
  -v --version       Displays app version number
  -h --help          Shows this help message
  -d --debug         Prints original node error messages to stderr on errors
  -e --file-encoding Sets a encoding to open <path> file, defaults to utf8
  -m --multiple      Allows the selection of multiple items
  -s --separator     Defines a separator to be used to split input into items
  -n --no-copy       Do not copy selected item(s) to clipboard

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

* Feedback wanted to confirm which features are available on a Windows cli

Contributing

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

Credits

iPipeTo wouldn't be possible if not for the amazing Inquirer.js that provides all these sweet interactive interfaces.

Created by

Ruy Adorno
Ruy Adorno

License

MIT © Ruy Adorno

install

npm i ipt

Downloadsweekly downloads

9,399

version

1.0.0

license

MIT

homepage

github.com

repository

Gitgithub

last publish

collaborators

  • avatar
Report a vulnerability