Show HN: LineSelect, shell utility to interactively select lines in a pipeline(github.com)
github.com
Show HN: LineSelect, shell utility to interactively select lines in a pipeline
https://github.com/chfritz/lineselect
25 comments
Some other options:
1. Piping into `fzf -m` (use tab to toggle selections and built-in search to filter options).
2. Percol https://github.com/mooz/percol (also has filtering, use ctrl-space to toggle selection).
1. Piping into `fzf -m` (use tab to toggle selections and built-in search to filter options).
2. Percol https://github.com/mooz/percol (also has filtering, use ctrl-space to toggle selection).
I always find myself needing a tool to interactively let me select which columns of an output to print. Basically I'm interactively writing something like 'awk {print $5, $10}' or whatever but I'm not sure which columns I need.
Anyone know anything like that? Ideally after running it'd somehow output which columns they were to use later.
Anyone know anything like that? Ideally after running it'd somehow output which columns they were to use later.
Ultimate plumber can do this.
https://github.com/akavel/up
https://github.com/akavel/up
`gum choose --no-limit`
https://github.com/charmbracelet/gum
https://github.com/charmbracelet/gum
Windows/PowerShell users should know there's a builtin cmdlet for this, Out-GridView. I mention this because I've used it for viewing objects in tabular form long before I realized it allows interactive selection. For example, selecting desktop files to delete:
Get-ChildItem -File ~\desktop | Out-GridView -PassThru | Remove-Item
or using aliases: ls -file ~\desktop | ogv -pass | riWow! It's a shame that it's GUI only, but really cool to see powershell including all of these nifty functions.
Yeah, a text-mode equivalent inside the console would have been much better. Something like the TBrowse system of dBase/Clipper I was using back in the 90s. Ah, the memories...
I'm definitely going to try this, but oy javascript. It's probably the reason this can be written with so little code but I would prefer a native binary that doesn't have the npm dependency.
Agreed. Less than 100 lines of code definitely has it's advantages, esp. for people who want to fork and extend it.
I typically use fzf for this purpose, and even on some rare occasions vim
fzf looks awesome, thanks for sharing. Didn't know about it. Do you have an example on how you can do this with vim?
Vim command has a ‘-‘ argument which instructs it to read from standard input. Here’s an example of interactively selecting files to delete in the current directory: find . -type f -name *.txt | vim - | xargs rm
Oof. Should have tried this one first before posting. The tricky part of this is that reading from standard input implies non-interactive mode.
Not as succinct but you can still pipe your output to vim, make your edits, run :w vimpipe to save your edits, and pipe the output of your vimpipe file to another command.
find . -type f -name \.txt | vim -; cat vimpipe | xargs rm
Not as succinct but you can still pipe your output to vim, make your edits, run :w vimpipe to save your edits, and pipe the output of your vimpipe file to another command.
find . -type f -name \.txt | vim -; cat vimpipe | xargs rm
There’s also an existing command line utility for this called vipe which I’ve always wanted to try, but never got around too. It’s part of moreutils: https://joeyh.name/code/moreutils/
with seq 1 10 | vim - | cat > x, I get "Vim: Warning: Output is not to a terminal" and the pipeline appears to hang, but actually the output is going to "x". In other words, your command deletes some unknown files depending on your terminal setup.
I used it in a shell script with a temp file. You could pretty easily write a shell script for this behavior though to be used in a pipeline
#!/bin/sh
TEMP=“$(mktmp)”
cat > “$TEMP”
$EDITOR “$TEMP”
cat “$TEMP”See also: 'vipe' from the excellent 'moreutils' package: https://joeyh.name/code/moreutils/
There are some other gems in this package. The ones I find myself using regularly are 'ts' and 'sponge' but I'm sure the useful subset depends a lot on the kind of work you are doing
There are some other gems in this package. The ones I find myself using regularly are 'ts' and 'sponge' but I'm sure the useful subset depends a lot on the kind of work you are doing
Similar Rust tools are checkline (checkbox line picker for stdin) and markline (markable line picker for stdin). I'm the dev.
https://github.com/SixArm/checkline
https://github.com/SixArm/markline
You may also want to know about similar tools such as vipe, peco, percol, canything, zaw, and fzf.
https://github.com/SixArm/checkline
https://github.com/SixArm/markline
You may also want to know about similar tools such as vipe, peco, percol, canything, zaw, and fzf.
Thanks! I've just looked at each of them and tested some. I think peco is the best one (and better than mine). Way bigger code base, but probably worth it.
To get retro, "whiptail" has been around forever (newt, or dialog) but that ends up with more horrible incantations like "whiptail --menu $(seq 1 10 | while read x; do echo $x $x; done)" - though whiptail does get you more options, like radiobox/checkbox instead of just menu, if you want multiple select - the focus is on text-ui for a user to select things that happens to produce an output, so it has lots of options for customization of screen layout rather than just being the kind of basic line-picker that you'd actually want day-to-day...
That's a really cool use of a tool. I like it very much. I'll probably use `fzf -m` for it, but thank you for the idea of putting it in the middle of a pipeline which I don't use fzf for enough in my interactive shell use.
>Also: please help me come up with a better name!
How about isel or iselect, for interactively select?
How about isel or iselect, for interactively select?
http://www.ossp.org/pkg/tool/iselect/ (already packaged in debian and ubuntu)
Tested on Linux but should also work on MacOS.
Also: please help me come up with a better name!