File tree Expand file tree Collapse file tree 2 files changed +35
-1
lines changed Expand file tree Collapse file tree 2 files changed +35
-1
lines changed Original file line number Diff line number Diff line change @@ -10,7 +10,7 @@ smart people at [Hashrocket](http://hashrocket.com/).
10
10
For a steady stream of TILs from a variety of rocketeers, checkout
11
11
[ til.hashrocket.com] ( https://til.hashrocket.com/ ) .
12
12
13
- _ 799 TILs and counting..._
13
+ _ 800 TILs and counting..._
14
14
15
15
---
16
16
@@ -747,6 +747,7 @@ _799 TILs and counting..._
747
747
- [ Search History] ( unix/search-history.md )
748
748
- [ Search Man Page Descriptions] ( unix/search-man-page-descriptions.md )
749
749
- [ Securely Remove Files] ( unix/securely-remove-files.md )
750
+ - [ Show A File Preview When Searching With FZF] ( unix/show-a-file-preview-when-searching-with-fzf.md )
750
751
- [ Show Disk Usage For The Current Directory] ( unix/show-disk-usage-for-the-current-directory.md )
751
752
- [ Show The Size Of Everything In A Directory] ( unix/show-the-size-of-everything-in-a-directory.md )
752
753
- [ SSH Escape Sequences] ( unix/ssh-escape-sequences.md )
Original file line number Diff line number Diff line change
1
+ # Show A File Preview When Searching With FZF
2
+
3
+ [ FZF] ( https://github.com/junegunn/fzf ) by itself is a great way to fuzzy
4
+ find files. It gets even better when you can view a preview of a file before
5
+ opening it up. The ` --preview ` flag lets you do just this.
6
+
7
+ Add a basic file preview with ` cat ` :
8
+
9
+ ``` bash
10
+ $ fzf --preview ' cat {}'
11
+ ```
12
+
13
+ The ` {} ` will get replaced a single-quoted string of the highlighted file.
14
+
15
+ You can spice up the preview a bit with color and line numbers using
16
+ [ ` bat ` ] ( https://github.com/sharkdp/bat ) :
17
+
18
+ ``` bash
19
+ $ fzf --preview ' bat --color "always" {}'
20
+ ```
21
+
22
+ The ` --color ` flag tells ` bat ` to produce syntax highlighted output even
23
+ though it isn't in interactive mode.
24
+
25
+ Lastly, you can keep it performant by only showing the first 100 lines:
26
+
27
+ ``` bash
28
+ $ fzf --preview ' bat --color "always" --line-range 0:100 {}'
29
+ ```
30
+
31
+ See ` man fzf ` for more details.
32
+
33
+ [ source] ( https://github.com/dkarter/dotfiles/blob/master/vimrc#L362 )
You can’t perform that action at this time.
0 commit comments