diff --git a/README.md b/README.md index 2847ac2..82079b9 100644 --- a/README.md +++ b/README.md @@ -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) diff --git a/unix/enable-multi-select-of-results-with-fzf.md b/unix/enable-multi-select-of-results-with-fzf.md new file mode 100644 index 0000000..ea28bb1 --- /dev/null +++ b/unix/enable-multi-select-of-results-with-fzf.md @@ -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.