fzf Preview Windows, Key Bindings, and Actions

Use previews, key bindings, execute actions, and dynamic UI changes to build powerful interactive pickers.

View
StandardDetailedCompact
Export
Copy the compact sheet, download it, or print it.
Download
`D` dense toggle · `C` copy all

Preview window

Show file or command previews beside the results list.

Preview file contents with bat

Render a syntax-highlighted preview for files.

bashANYpreviewbatfiles
bash
fzf --preview 'bat --style=numbers --color=always --line-range :200 {}'
Notes

A common choice because bat provides color and line numbers.

Place preview on the right

Move the preview window and size it.

bashANYpreview-windowlayout
bash
find . -type f | fzf --preview 'head -100 {}' --preview-window=right,60%
Notes

The preview window is highly configurable for position, size, wrap, border, and follow behavior.

Toggle preview visibility

Start with the preview hidden and toggle it on demand.

bashANYtoggle-previewbindings
bash
find . -type f | fzf --preview 'bat --color=always {}' --bind 'ctrl-/:toggle-preview'
Notes

Useful when you want a compact list by default but still need previews occasionally.

Scroll the preview pane

Add custom preview scrolling bindings.

bashANYpreviewscrollbindings
bash
find . -type f | fzf --preview 'bat --color=always {}' --bind 'ctrl-u:preview-half-page-up,ctrl-d:preview-half-page-down'
Notes

Helpful for long previews when you want keyboard-only navigation.

Bind actions

Attach commands and UI behavior to keys and events.

Select all items with a key binding

Bind a key to select all results in multi-select mode.

bashANYbindselect-allmulti
bash
seq 100 | fzf -m --bind 'ctrl-a:select-all'
Notes

Bindings make fzf much more powerful than a passive filter.

Clear all selections

Bind a key to deselect all marked entries.

bashANYbinddeselect-all
bash
seq 100 | fzf -m --bind 'ctrl-x:deselect-all'
Notes

Useful alongside multi-select workflows.

Run a command on the current item

Open the selected file without leaving fzf permanently.

bashANYexecuteeditorbind
bash
find . -type f | fzf --bind 'enter:execute(vim {})'
Notes

The execute action launches a subprocess using the current item.

Replace fzf with another process

Turn the selection directly into a new foreground program.

bashANYbecomeeditorbind
bash
find . -type f | fzf --bind 'enter:become(vim {})'
Notes

become is ideal when fzf is only a launcher and should hand control to the next process.

Change the prompt dynamically

Update the prompt based on a key or event.

bashANYchange-promptuibind
bash
printf '%s
' files dirs | fzf --bind 'ctrl-f:change-prompt(Files> ),ctrl-d:change-prompt(Dirs> )'
Notes

Useful in advanced menus that switch modes.

Update the header dynamically

Modify informational text in response to events.

bashANYheadertransformevents
bash
printf '%s
' alpha beta gamma | fzf --bind 'focus:transform-header:echo Focused on {1}'
Notes

Dynamic headers can make interactive dashboards more self-explanatory.

Recommended next

No recommendations yet.