LineSelect
A shell utility to interactively select lines from stdin and output them to stdout. This allows you to effectively pause the pipeline to make a manual selection before the pipeline, or other composed command, continues.
Introduction:
In command-line environments, efficiently selecting lines from standard input is often a necessity. Imagine having a powerful shell utility that enables interactive line selection directly from stdin. In this blog post, we will explore the capabilities and advantages of a versatile shell utility designed to streamline the line selection process. Discover how this innovative tool empowers users to interactively choose lines from stdin, enhancing productivity and simplifying data processing tasks.
graph LR; a[some pipeline]-->|some lines| lineselect; lineselect-->|a subset of those lines| b[some other pipeline];
The applications are end-less
For example, select files to delete
ls | lineselect | xargs rm
Select files from a list sorted by size and delete those files
ls -lS | lineselect | tr -s ' ' | cut -d ' ' -f 9 | xargs rm
Select docker containers to stop:
docker stop $(docker ps | lineselect | cut -d ' ' -f 1)
(z)Grep some some log files of interest:
ls dpkg.log* | lineselect | xargs zgrep upgrade
Demo Video
Install
$ npm install -g lineselect
Acknowledgements
Built using the amazing React-for-CLI ๐ Ink library . With the key insight of writing directly to the TTY, by-passing stdout, to render the TUI without messing up the eventual output to stdout taken from https://github.com/geier/choose and https://superuser.com/a/742789/282396 ๐.