Skip to main content

fzf has a preview mode

1 min read

Today I learned that fzf has a preview mode.

fzf is a general-purpose command-line fuzzy finder

Now you can not only find any file using fuzzy searching on your computer but you can also preview the contents of the file before opening it.

fzf preview window

Here I'm calling fzf with the --preview flag and using bat to preview the contents of the file which gives me syntax highlighting.

 fzf --preview 'bat --color=always {}'

You can see the the standard fzf search interface on the left and now on the right, we have bat displaying the contents of the file with syntax highlighting.



So now I can alias this to fzfp for fzf preview so I have a quick way to search and preview files.

alias fzfp='fzf --preview "bat --color=always {}"'

Github Links

© 2021 by Madole.
GitHub Repository
Last build: 1718543671768