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.
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.
Alias
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 {}"'