Interactive Pipe To: The missing cli interactive workflow
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!
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.
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.
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.
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.
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!
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 onealias 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 irebasealias 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
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 it easily using npm:
$ npm install -g ipt
Keep in mind that you'll need to have at least Node.js > 0.12 installed
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.
curl -fsSL https://raw.githubusercontent.com/ruyadorno/ipt/master/gallery.sh >> ~/.bash_profile
curl -fsSL https://raw.githubusercontent.com/ruyadorno/ipt/master/gallery.sh >> ~/.bashrc
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 to clipboard
Supported OS Terminals
iPipeTo should run just fine in any of the Inquirer.js supported terminals:
- Mac OS:
- Linux (Ubuntu, openSUSE, Arch Linux, etc):
- gnome-terminal (Terminal GNOME)
* Feedback wanted to confirm which features are available on a Windows cli
Bug fixes / code changes: Please provide tests covering your changes, update docs accordingly and keep your changes to a single commit.
iPipeTo wouldn't be possible if not for the amazing Inquirer.js that provides all these sweet interactive interfaces.
MIT © Ruy Adorno