Preview file contents with bat
Render a syntax-highlighted preview for files.
fzf --preview 'bat --style=numbers --color=always --line-range :200 {}'A common choice because bat provides color and line numbers.
Use previews, key bindings, execute actions, and dynamic UI changes to build powerful interactive pickers.
Show file or command previews beside the results list.
Render a syntax-highlighted preview for files.
fzf --preview 'bat --style=numbers --color=always --line-range :200 {}'A common choice because bat provides color and line numbers.
find . -type f | fzf --preview 'head -100 {}' --preview-window=right,60%The preview window is highly configurable for position, size, wrap, border, and follow behavior.
find . -type f | fzf --preview 'bat --color=always {}' --bind 'ctrl-u:preview-half-page-up,ctrl-d:preview-half-page-down'Helpful for long previews when you want keyboard-only navigation.
Attach commands and UI behavior to keys and events.
Bind a key to select all results in multi-select mode.
seq 100 | fzf -m --bind 'ctrl-a:select-all'Bindings make fzf much more powerful than a passive filter.
seq 100 | fzf -m --bind 'ctrl-x:deselect-all'Useful alongside multi-select workflows.
Open the selected file without leaving fzf permanently.
find . -type f | fzf --bind 'enter:execute(vim {})'The execute action launches a subprocess using the current item.
Turn the selection directly into a new foreground program.
find . -type f | fzf --bind 'enter:become(vim {})'become is ideal when fzf is only a launcher and should hand control to the next process.
printf '%s
' files dirs | fzf --bind 'ctrl-f:change-prompt(Files> ),ctrl-d:change-prompt(Dirs> )'Useful in advanced menus that switch modes.
Modify informational text in response to events.
printf '%s
' alpha beta gamma | fzf --bind 'focus:transform-header:echo Focused on {1}'Dynamic headers can make interactive dashboards more self-explanatory.