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
Preview file contents with bat
fzf --preview 'bat --style=numbers --color=always --line-range :200 {}'

# Render a syntax-highlighted preview for files.

Place preview on the right
find . -type f | fzf --preview 'head -100 {}' --preview-window=right,60%

# Move the preview window and size it.

Toggle preview visibility
find . -type f | fzf --preview 'bat --color=always {}' --bind 'ctrl-/:toggle-preview'

# Start with the preview hidden and toggle it on demand.

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

# Add custom preview scrolling bindings.

## Bind actions
Select all items with a key binding
seq 100 | fzf -m --bind 'ctrl-a:select-all'

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

Clear all selections
seq 100 | fzf -m --bind 'ctrl-x:deselect-all'

# Bind a key to deselect all marked entries.

Run a command on the current item
find . -type f | fzf --bind 'enter:execute(vim {})'

# Open the selected file without leaving fzf permanently.

Replace fzf with another process
find . -type f | fzf --bind 'enter:become(vim {})'

# Turn the selection directly into a new foreground program.

Change the prompt dynamically
printf '%s
' files dirs | fzf --bind 'ctrl-f:change-prompt(Files> ),ctrl-d:change-prompt(Dirs> )'

# Update the prompt based on a key or event.

Update the header dynamically
printf '%s
' alpha beta gamma | fzf --bind 'focus:transform-header:echo Focused on {1}'

# Modify informational text in response to events.

Recommended next

No recommendations yet.