mirror of
https://github.com/jbranchaud/til
synced 2026-01-02 22:58:01 +00:00
Add Enable Multi-Select Of Results With fzf as a unix til
This commit is contained in:
@@ -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)
|
||||
|
||||
25
unix/enable-multi-select-of-results-with-fzf.md
Normal file
25
unix/enable-multi-select-of-results-with-fzf.md
Normal 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.
|
||||
Reference in New Issue
Block a user