1
0
mirror of https://github.com/jbranchaud/til synced 2026-01-03 07:08:01 +00:00

Add Enable Multi-Select Of Results With fzf as a unix til

This commit is contained in:
jbranchaud
2021-03-07 20:11:11 -06:00
parent 10972e4192
commit c8678f7293
2 changed files with 27 additions and 1 deletions

View File

@@ -10,7 +10,7 @@ pairing with smart people at Hashrocket.
For a steady stream of TILs, [sign up for my newsletter](https://tinyletter.com/jbranchaud).
_1075 TILs and counting..._
_1076 TILs and counting..._
---
@@ -1007,6 +1007,7 @@ _1075 TILs and counting..._
- [Display Free Disk Space](unix/display-free-disk-space.md)
- [Display The Contents Of A Directory As A Tree](unix/display-the-contents-of-a-directory-as-a-tree.md)
- [Do Not Overwrite Existing Files](unix/do-not-overwrite-existing-files.md)
- [Enable Multi-Select Of Results With fzf](unix/enable-multi-select-of-results-with-fzf.md)
- [Exclude A Directory With Find](unix/exclude-a-directory-with-find.md)
- [Figure Out The Week Of The Year From The Terminal](unix/figure-out-the-week-of-the-year-from-the-terminal.md)
- [File Type Info With File](unix/file-type-info-with-file.md)

View File

@@ -0,0 +1,25 @@
# Enable Multi-Select Of Results With fzf
You can pipe the output of any command to
[`fzf`](https://github.com/junegunn/fzf) and it will display it line-by-line in
a list that you can then fuzzy-find against.
By default you get to pick _one_ of those results. That result will go to
stdout, either printing to the terminal or being piped to the next command.
For some combinations of commands, it makes more sense to be able to select
_multiple_ results. `fzf` supports this with the `-m` (or `--multi`) flag.
```bash
$ ls | fzf -m | xargs cat
```
For instance, this series of commands pipes the output of `ls` (files and
directoris) to `fzf`. The `-m` flag means that you can hit `Tab` (or
`Shift+Tab`) to select multile entries. When you hit enter, each of the
selected entries will be executed one by one with `cat`.
I show a slightly more practical example of this in [Make One-Line Commands
Interactive with fzf](https://www.youtube.com/watch?v=wf5eXdwfVws).
See `man fzf` for more details.