fzf(1)

๐Ÿ’– fzf(1) โ€” fzf, the command-line fuzzy finder ๐Ÿ’–

okay bestie, pull up a chair, we're learning fzf and honestly it's about to be your whole personality ๐Ÿซถ

โœจ NAME โœจ

fzf โ€” a command-line fuzzy finder. that's it. that's the name. it's giving main character energy and it deserves to. ๐Ÿ‘‘


โœจ SYNOPSIS โœจ

fzf [options]

likeโ€ฆ that's the whole synopsis. just options. she's flexible, she contains multitudes. ๐ŸŒˆ


โœจ DESCRIPTION โœจ

so fzf is an interactive filter program for any kind of list. any kind. lists of files, lists of commits, lists of your regrets, whatever you've got. ๐Ÿ“

and the reason she's iconic is the "fuzzy" matching algorithm โ€” which means you can type in patterns with characters omitted and still get the results you actually want. you don't type the whole thing. you type a vibe. fzf gets it. no cap. โœจ


โœจ OPTIONS โœจ

๐ŸŽ€ NOTE ๐ŸŽ€

most long options have the opposite version, and you get it by slapping a --no- prefix on the front. so --extended has --no-extended. silly and simple. ๐Ÿ’…


  • -x, --extended โ€” Extended-search mode. this is enabled by default, bestie, she comes pre-slaying. you can turn it off with +x or --no-extended if you're feeling feral. ๐Ÿ™ˆ
  • -e, --exact โ€” Enable exact-match. no fuzz, just precision. ๐Ÿ’…
  • -i, --ignore-case โ€” Case-insensitive match. heads up though, the default is smart-case match, not this. โœจ
  • +i, --no-ignore-case โ€” Case-sensitive match.
  • --smart-case โ€” Smart-case match, and yes this is the default behavior. here's the tea: the search is case-insensitive by default, but the moment your query contains any uppercase letters, it flips to case-sensitive. she's reading the room. ๐Ÿ‘‘
  • --literal โ€” Do not normalize latin script letters for matching. like, take the letters literally. periodt. โญ
  • --scheme=SCHEME โ€” Choose scoring scheme tailored for different types of input. options are:
    • default โ€” Generic scoring scheme designed to work well with any type of input. the safe pick, the reliable bestie.
    • path โ€” Additional bonus point is only given to the characters after path separator. You might want to choose this scheme over default if you have many files with spaces in their paths. This also sets --tiebreak=pathname,length, to prioritize matches occurring in the tail element of a file path. lowkey obsessed with how specific this is. ๐Ÿฆ‹
    • history โ€” Scoring scheme well suited for command history or any input where chronological ordering is important. No additional bonus points are given so that we give more weight to the chronological ordering. This also sets --tiebreak=index. ๐ŸŒธ

and the plot twist: fzf chooses path scheme when the input is a TTY device โ€” that's when fzf would start its built-in walker or run $FZF_DEFAULT_COMMAND โ€” and there is no reload or transform action bound to start event. Otherwise, it chooses default scheme. iykyk. ๐Ÿ’ซ

  • --algo=TYPE โ€” Fuzzy matching algorithm. default: v2. the two choices are:
    • v2 โ€” Optimal scoring algorithm (quality). pretty AND correct.
    • v1 โ€” Faster but not guaranteed to find the optimal result (performance). she's fast, she's loose, she might miss. ๐Ÿ’€
  • -n, --nth=N[,..] โ€” Comma-separated list of field index expressions for limiting search scope. See FIELD INDEX EXPRESSION for the details. ๐ŸŽ€

and here's the important bit bestie, don't skip it: When you use this option with --with-nth, the field index expressions are calculated against the transformed lines (unlike in --preview where fields are extracted from the original lines) because fzf doesn't allow searching against the hidden fields. no peeking behind the curtain. ๐Ÿ™ˆ

  • --with-nth=N[,..] or TEMPLATE โ€” Transform the presentation of each line using the field index expressions. For advanced transformation, you can provide a template containing field index expressions in curly braces. When you use a template, the trailing delimiter is stripped from each expression, giving you more control over the output. {n} in template evaluates to the zero-based ordinal index of the line. ๐Ÿช„

e.g.

# Single expression: drop the first field
echo foo bar baz | fzf --with-nth 2..

# Use template to rearrange fields
echo foo,bar,baz | fzf --delimiter , --with-nth '{n},{1},{3},{2},{1..2}'

also: change-with-nth action is only available when --with-nth is set. and when --with-nth is used, fzf retains the original input lines in memory so they can be re-transformed on the fly (e.g. --with-nth .. to keep the original presentation). โš ๏ธ This increases memory usage, so only use --with-nth when you actually need field transformation. โš ๏ธ she's powerful but she eats RAM, respect her.

  • --accept-nth=N[,..] or TEMPLATE โ€” Define which fields to print on accept. The last delimiter is stripped from the output. For advanced transformation, you can provide a template containing field index expressions in curly braces. When you use a template, the trailing delimiter is stripped from each expression, giving you more control over the output. {n} in template evaluates to the zero-based ordinal index of the line. โœจ

e.g.

# Single expression
echo foo bar baz | fzf --accept-nth 2

# Template
echo foo bar baz | fzf --accept-nth 'Index: {n}, 1st: {1}, 2nd: {2}, 3rd: {3}'
  • +s, --no-sort โ€” Do not sort the result. chaos mode activated. ๐Ÿ’€
  • -d, --delimiter=STR โ€” Field delimiter regex for --nth, --with-nth, and field index expressions. default: AWK-style. ๐ŸŽ€
  • --tail=NUM โ€” Maximum number of items to keep in memory. This is useful when you want to browse an endless stream of data (e.g. log stream) with fzf while limiting memory usage. queen of boundaries. ๐Ÿ‘‘

e.g.

# Interactive filtering of a log stream
tail -f *.log | fzf --tail 100000 --tac --no-sort --exact
  • --disabled โ€” Do not perform search. With this option, fzf becomes a simple selector interface rather than a "fuzzy finder". You can later enable the search using enable-search or toggle-search action. she's resting. don't perceive her. ๐Ÿ˜ญ
  • --tiebreak=CRI[,..] โ€” Comma-separated list of sort criteria to apply when the scores are tied. because sometimes everyone is equally slaying and someone has to go first:
    • length โ€” Prefers line with shorter length
    • chunk โ€” Prefers line with shorter matched chunk (delimited by whitespaces)
    • pathname โ€” Prefers line with matched substring in the file name of the path
    • begin โ€” Prefers line with matched substring closer to the beginning
    • end โ€” Prefers line with matched substring closer to the end
    • index โ€” Prefers line that appeared earlier in the input stream

the rules of the game: ๐ŸŽฏ

  • Each criterion should appear only once in the list
  • index is only allowed at the end of the list
  • index is implicitly appended to the list when not specified
  • Default is length (or equivalently length,index)
  • If end is found in the list, fzf will scan each line backwards

๐Ÿ“ฅ INPUT/OUTPUT ๐Ÿ“ค

  • --read0 โ€” Read input delimited by ASCII NUL characters instead of newline characters. ๐Ÿซง
  • --print0 โ€” Print output delimited by ASCII NUL characters instead of newline characters. ๐Ÿซง
  • --ansi โ€” Enable processing of ANSI color codes. let her be colorful, she deserves it. ๐ŸŒˆ
  • --sync โ€” Synchronous search for multi-staged filtering. If specified, fzf will launch the finder only after the input stream is complete and the initial filtering and the associated actions (bound to any of start, load, result, result-final, or focus) are complete. she waits for the whole story before she speaks. ๐ŸŽ€

e.g.

# Avoid rendering both fzf instances at the same time
fzf --multi | fzf --sync

# fzf will not render intermediate states
(sleep 1; seq 1000000; sleep 1) |
  fzf --sync --query 5 --listen --bind start:up,load:up,result:up,focus:change-header:Ready
  • --no-tty-default โ€” Make fzf search for the current TTY device via standard error instead of defaulting to /dev/tty. This option avoids issues when launching emacsclient from within fzf. Alternatively, you can change the default TTY device by setting --tty-default=DEVICE_NAME. ๐Ÿงš

๐ŸŽจ GLOBAL STYLE ๐ŸŽจ

  • --style=PRESET โ€” Apply a style preset [default|minimal|full[:BORDER_STYLE]]. glow up, available in three flavors. ๐Ÿ’…
  • --color=[BASE_SCHEME][,COLOR_NAME[:ANSI_COLOR][:ANSI_ATTRIBUTES]]... โ€” Color configuration. The name of the base color scheme is followed by custom color mappings. Each entry is separated by a comma and/or whitespaces. โœจ

BASE SCHEME:

(default: dark on 256-color terminal, otherwise base16; If NO_COLOR is set, bw)
  • dark โ€” Color scheme for dark terminal
  • light โ€” Color scheme for light terminal
  • base16 โ€” Color scheme using base 16 colors (alias: 16)
  • bw โ€” No colors (equivalent to --no-color)

COLOR NAMES: โ€” this is the whole entire family tree bestie, every name you can drop into --color ๐Ÿ’–

  • fg โ€” the text
    • list-fg โ€” text in the list section
      • selected-fg โ€” selected line text
    • preview-fg โ€” preview window text
  • bg โ€” the background
    • list-bg โ€” list section background
      • selected-bg โ€” selected line background
    • preview-bg โ€” preview window background
    • input-bg โ€” input window background
    • header-bg โ€” header window background
    • footer-bg โ€” footer window background
  • hl โ€” highlighted substrings
    • selected-hl โ€” highlighted substrings in the selected line
  • current-fg (fg+) โ€” text (current line)
  • current-bg (bg+) โ€” background (current line)
    • gutter โ€” gutter on the left
  • current-hl (hl+) โ€” highlighted substrings (current line)
  • alt-bg โ€” alternate background color to create striped lines
  • alt-gutter โ€” alternate gutter color to create the striped pattern
  • query (input-fg) โ€” query string
    • ghost โ€” ghost text (--ghost, dim applied by default)
    • disabled โ€” query string when search is disabled (--disabled)
  • info โ€” info line (match counters)
  • border โ€” border around the window (--border and --preview)
    • list-border โ€” border around the list section (--list-border)
      • scrollbar โ€” scrollbar
      • separator โ€” horizontal separator on info line
      • gap-line โ€” horizontal line on each gap
    • preview-border โ€” border around the preview window (--preview)
      • preview-scrollbar โ€” scrollbar
    • input-border โ€” border around the input window (--input-border)
    • header-border โ€” border around the header window (--header-border)
    • footer-border โ€” border around the footer window (--footer-border)
  • label โ€” border label (--border-label, --list-label, --input-label, and --preview-label)
    • list-label โ€” border label of the list section (--list-label)
    • preview-label โ€” border label of the preview window (--preview-label)
    • input-label โ€” border label of the input window (--input-label)
    • header-label โ€” border label of the header window (--header-label)
    • footer-label โ€” border label of the footer window (--footer-label)
  • prompt โ€” prompt
  • pointer โ€” pointer to the current line
  • marker โ€” multi-select marker
  • spinner โ€” streaming input indicator
  • header (header-fg) โ€” header
  • footer (footer-fg) โ€” footer
  • nth โ€” parts of the line specified by --nth (only supports attributes)
  • nomatch โ€” non-matching items in raw mode (default: dim)

ANSI COLORS: โœจ

  • -1 โ€” default terminal foreground/background color (or the original color of the text)
  • 0 ~ 15 โ€” the 16 base colors:
    • black
    • red
    • green
    • yellow
    • blue
    • magenta
    • cyan
    • white
    • bright-black (gray | grey)
    • bright-red
    • bright-green
    • bright-yellow
    • bright-blue
    • bright-magenta
    • bright-cyan
    • bright-white
  • 16 ~ 255 โ€” ANSI 256 colors
  • #rrggbb โ€” 24-bit colors

ANSI ATTRIBUTES: (Only applies to foreground colors) โ€” literally only the foreground, don't try it anywhere else ๐Ÿ™ˆ

  • regular โ€” clear previously set attributes; should precede the other ones
  • strip โ€” remove colors
  • bold
  • underline
  • underline-double
  • underline-curly
  • underline-dotted
  • underline-dashed
  • reverse
  • dim
  • italic
  • strikethrough

EXAMPLES: ๐ŸŒˆ the aesthetic inspo, periodt

# Seoul256 theme with 8-bit colors
# (https://github.com/junegunn/seoul256.vim)
fzf --color='bg:237,bg+:236,info:143,border:240,spinner:108' \
    --color='hl:65,fg:252,header:65,fg+:252' \
    --color='pointer:161,marker:168,prompt:110,hl+:108'

# Seoul256 theme with 24-bit colors
fzf --color='bg:#4B4B4B,bg+:#3F3F3F,info:#BDBB72,border:#6B6B6B,spinner:#98BC99' \
    --color='hl:#719872,fg:#D9D9D9,header:#719872,fg+:#D9D9D9' \
    --color='pointer:#E12672,marker:#E17899,prompt:#98BEDE,hl+:#98BC99'

# Seoul256 light theme with 24-bit colors, each entry separated by whitespaces
fzf --style full --color='
  fg:#616161 fg+:#616161
  bg:#ffffff bg+:#e9e9e9 alt-bg:#f1f1f1
  hl:#719872 hl+:#719899
  pointer:#e12672 marker:#e17899
  header:#719872
  spinner:#719899 info:#727100
  prompt:#0099bd query:#616161
  border:#e1e1e1
'

  • --no-color โ€” disable colors. bye bye color bestie ๐Ÿ˜ญ
  • --no-bold โ€” do not use bold text
  • --black โ€” use black background

โœจ DISPLAY MODE โœจ

  • --height=[~][-]HEIGHT[%] โ€” show the fzf window below the cursor with the height you give it, instead of hogging the whole screen ๐Ÿซถ

If you pass a negative value, the height gets calculated as the terminal height minus that number.

fzf --height=-1

Prefix it with ~ and fzf will auto-determine the height in the range based on the input size. And yes, you can combine ~ with a negative value ๐Ÿ’…

# Will not take up 100% of the screen
seq 5 | fzf --height=~100%

# Adapt to input size, up to terminal height minus 1
seq 5 | fzf --height=~-1

Adaptive height has the following limitations, bestie, read them fr fr:

  • Cannot be used with top/bottom margin and padding given in percent size
  • It will not find the right size when there are multi-line items
  • fzf cannot start until the input ends or exceeds the height, so a stream that stays below it will delay the first render
  • --min-height=HEIGHT[+] โ€” minimum height for when --height is given as a percentage. Add + and it auto-increases the value according to the other layout options so that the specified number of items are visible in the list section (default: 10+). Ignored when --height is not specified or set as an absolute value.
  • --popup[=[center|top|bottom|left|right][,SIZE[%]][,SIZE[%]][,border-native]] โ€” start fzf in a tmux or Zellij floating pane (default center,50%). Requires tmux 3.3+ or Zellij 0.44+. This option is ignored if you are not running fzf inside tmux or Zellij. --tmux is an alias for this option. ๐Ÿ‘‘

On tmux 3.7 or above and on Zellij, the floating pane is not modal; you can switch to other panes and windows while fzf is running, and move and resize the pane with the mouse. The native border of the pane is the handle for moving and resizing it, so it is used by default and border-native is implied. --border-label is displayed on the native border, and change-border-label and transform-border-label update it (--border-label-pos is ignored). On tmux, fzf holds the label in the @fzf-border-label option of the pane and sets its pane-border-format to read it back, so the label is displayed if pane-border-status is enabled in tmux. The title of the pane is left alone. On Zellij, the label is the name of the pane.

fzf draws its own border instead when a border style is explicitly specified with --border, so that it is the only border shown. none and line are treated as no border. Give border-native to keep the native border nonetheless. On tmux, the fzf-drawn border is shown in a modal popup, since the native border of a tmux floating pane cannot be removed; this is also the case on tmux versions below 3.7. ๐Ÿ’€

e.g.

# Popup in the center with 70% width and height
fzf --popup 70%

# Popup on the left with 40% width and 100% height
fzf --popup right,40%

# Popup on the bottom with 100% width and 30% height
fzf --popup bottom,30%

# Popup on the top with 80% width and 40% height
fzf --popup top,80%,40%

# Popup with a native tmux or Zellij border in the center with 80% width and height
fzf --popup center,80%,border-native

๐ŸŽ€ LAYOUT ๐ŸŽ€

  • --layout=LAYOUT โ€” pick your layout (default: default) ๐Ÿฆ‹
    • default โ€” display from the bottom of the screen
    • reverse โ€” display from the top of the screen
    • reverse-list โ€” display from the top of the screen, prompt at the bottom
  • --reverse โ€” a synonym for --layout=reverse
  • --margin=MARGIN โ€” comma-separated expression for margins around the finder.
    • TRBL โ€” same margin for top, right, bottom, and left
    • TB,RL โ€” vertical, horizontal margin
    • T,RL,B โ€” top, horizontal, bottom margin
    • T,R,B,L โ€” top, right, bottom, left margin

Each part can be given as an absolute number, or as a percentage relative to the terminal size with a % suffix.

e.g.

fzf --margin 10%
fzf --margin 1,5%
  • --padding=PADDING โ€” comma-separated expression for padding inside the border. Padding is distinguishable from margin only when the --border option is used. ๐ŸŽจ

e.g.

fzf --margin 5% --padding 5% --border --preview 'cat {}' \
    --color bg:#222222,preview-bg:#333333
  • TRBL โ€” same padding for top, right, bottom, and left
  • TB,RL โ€” vertical, horizontal padding
  • T,RL,B โ€” top, horizontal, bottom padding
  • T,R,B,L โ€” top, right, bottom, left padding
  • --border[=STYLE] โ€” draw border around the finder
  • rounded โ€” border with those cute rounded corners (this one's the default, bestie) ๐ŸŽ€
  • sharp โ€” border with sharp corners
  • bold โ€” border with bold lines
  • double โ€” border with double lines
  • dashed โ€” border with dashed lines and rounded corners
  • block โ€” border made of block elements; lowkey the move when you're using different background colors
  • thinblock โ€” border using legacy computing symbols; fair warning, this may not show up on some terminals ๐Ÿ˜ญ
  • horizontal โ€” horizontal lines sitting above and below the finder
  • vertical โ€” vertical lines down each side of the finder
  • line โ€” a single line border (position is automatically determined)
  • top (aka up) ๐Ÿ‘†
  • bottom (aka down) ๐Ÿ‘‡
  • left ๐Ÿ‘ˆ
  • right ๐Ÿ‘‰
  • none โ€” bye border ๐Ÿ’€

So if you're on a terminal emulator where every single box-drawing character eats 2 columns, literally try --ambidouble. And if the border still looks cursed after that? Set --no-unicode, periodt.

Also, ngl, the line style draws a single separator line at the top when --height is used.


๐ŸŽ€ --border-label[=LABEL] ๐ŸŽ€

Bestie, this is the label you print on the horizontal border line. Should be used with one of these --border options:

  • rounded
  • sharp
  • bold
  • double
  • horizontal
  • top (up)
  • bottom (down)

e.g.

# ANSI color codes are supported
# (with https://github.com/busyloop/lolcat)
label=$(curl -s http://metaphorpsum.com/sentences/1 | lolcat -f)

# Border label at the center
fzf --height=10 --border --border-label="โ•ข $label โ•Ÿ" --color=label:italic:black

# Left-aligned (positive integer)
fzf --height=10 --border --border-label="โ•ข $label โ•Ÿ" --border-label-pos=3 --color=label:italic:black

# Right-aligned (negative integer) on the bottom line (:bottom)
fzf --height=10 --border --border-label="โ•ข $label โ•Ÿ" --border-label-pos=-3:bottom --color=label:italic:black
The label variable in that example is the SHELL VARIABLE, not the label element of --color. But also, the --color=label:italic:black DOES style it. Both things! โœจ

๐ŸŒธ --border-label-pos[=N[:top|bottom]] ๐ŸŒธ

Where does the border label live on the border line? Your call, queen. Give it a positive integer and it's the column position counted from the left. Give it a negative integer and the label gets right-aligned. By default the label is printed on the top border line โ€” add :bottom to yeet it onto the border line on the bottom instead. And the default value 0 (or center) puts that label dead center on the border line. ๐Ÿ’…


๐Ÿ’– LIST SECTION ๐Ÿ’–

  • -m, --multi[=MAX] โ€” turns on multi-select with Tab/Shift+Tab. It optionally takes an integer argument, which is the max number of items you're allowed to select. ๐Ÿ‘‘
  • +m, --no-multi โ€” turns multi-select back off
  • --highlight-line โ€” highlights the whole current line, not just the matching bits โœจ
  • --cycle โ€” enables cyclic scroll, so you loop around like a lil carousel ๐ŸŽ 
  • --wrap[=MODE] โ€” enables line wrap. MODE can be char (the default) or word. The word mode wraps lines at word boundaries (spaces and tabs) instead of at arbitrary character positions. Oh and --wrap-word is a synonym for --wrap=word. โœจ
  • --wrap-sign=INDICATOR โ€” the indicator for wrapped lines. Default is 'โ†ณ ' or '> ' depending on --no-unicode.
  • --no-multi-line โ€” disables the multi-line display of items when you're using --read0
  • --raw โ€” raw mode activated ๐Ÿ’… non-matching items still get displayed, just in a dimmed color
  • --track โ€” makes fzf track the current selection when the result list gets updated. Super useful when you're browsing logs with fzf and sorting is disabled. It is not recommended to use this one with --tac because the resulting behavior can be confusing. ๐Ÿ˜ญ

When --id-nth is also set, fzf enables field-based tracking across reloads. See --id-nth for details.

Without --id-nth, --track uses index-based tracking that does not persist across reloads.

e.g.

# Index-based tracking (does not persist across reloads)
git log --oneline --graph --color=always | nl |
    fzf --ansi --track --no-sort --layout=reverse-list

# Track by first field (e.g. pod name) across reloads
kubectl get pods | fzf --track --id-nth 1 --header-lines=1 \
    --bind 'ctrl-r:reload:kubectl get pods'
  • --id-nth=N[,..] โ€” defines the item identity fields for cross-reload operations. When it's set, fzf uses those specified fields to identify items across reload and reload-sync. ๐Ÿซถ

With --track, fzf extracts the tracking key from the current item using the nth expression and searches for a matching item in the reloaded list. While it's searching, the UI is blocked (query input and cursor movement get disabled, and the prompt is dimmed). With reload, that blocked state clears as soon as the match is found in the stream. With reload-sync, the blocked state sticks around until the entire stream is complete. Press Escape or Ctrl+C to cancel the blocked state without quitting fzf. โš ๏ธ

The info line shows +T* (or +t* for one-off tracking) while the search is in progress.

With --multi, selected items are preserved across reload-sync by matching their identity fields in the reloaded list. Obsessed. ๐Ÿ˜Œ

e.g.

# Track and preserve selections by pod name across reloads
kubectl get pods | fzf --multi --track --id-nth 1 --header-lines=1 \
    --bind 'ctrl-r:reload-sync:kubectl get pods'
  • --tac โ€” reverses the order of the input ๐Ÿ”„

e.g.

history | fzf --tac --no-sort
  • --gap[=N] โ€” renders empty lines between each item, lil breathing room for the girlies ๐ŸŒฌ๏ธ
  • --gap-line[=STR] โ€” the given string gets repeated to draw a horizontal line on each gap (default: 'โ”ˆ' or '-' depending on --no-unicode).
  • --freeze-left=N โ€” number of fields to freeze on the left. ๐ŸงŠ
  • --freeze-right=N โ€” number of fields to freeze on the right. ๐ŸงŠ
  • --keep-right โ€” keeps the right end of the line visible when it's too long. Only effective when the query string is empty. Use --freeze-right=1 instead if you want that last field to always be visible even when the query isn't empty.
  • --scroll-off=LINES โ€” number of screen lines to keep above or below when scrolling to the top or to the bottom (default: 3).
  • --no-hscroll โ€” disables horizontal scroll ๐Ÿšซ
  • --hscroll-off=COLS โ€” number of screen columns to keep to the right of the highlighted substring (default: 10). Heads up: setting this to a large value will cause the text to be positioned in the center of the screen.
  • --jump-labels=CHARS โ€” the label characters used for jump mode. ๐Ÿฆ˜
  • --gutter=CHAR โ€” the character used for the gutter column (default: 'โ–Œ' unless --no-unicode is given)
  • --gutter-raw=CHAR โ€” the character used for the gutter column in raw mode (default: 'โ––' unless --no-unicode is given)
  • --pointer=STR โ€” the pointer to the current line (default: 'โ–Œ' or '>' depending on --no-unicode) ๐Ÿ‘‰
  • --marker=STR โ€” the multi-select marker (default: 'โ”ƒ' or '>' depending on --no-unicode)
  • --marker-multi-line=STR โ€” the multi-select marker for multi-line entries. 3 elements for top, middle, and bottom. (default: 'โ•ปโ”ƒโ•น' or '.|'' depending on --no-unicode) ๐Ÿ’…
  • --ellipsis=STR โ€” the ellipsis to show when a line is truncated (default: 'ยทยท')
  • --tabstop=SPACES โ€” number of spaces for a tab character (default: 8)
  • --scrollbar=CHAR1[CHAR2] โ€” use the given character to render the scrollbar. (default: 'โ”‚' or ':' depending on --no-unicode). The optional CHAR2 is used to render the scrollbar of the preview window.
  • --no-scrollbar โ€” don't display the scrollbar at all. A synonym for --scrollbar=''.
  • --list-border[=STYLE] โ€” draws a border around the list section. Just so you know, the line style is not supported for this border. ๐Ÿ™ˆ
  • --list-label[=LABEL] โ€” the label to print on the list border ๐Ÿท๏ธ
  • --list-label-pos[=N[:top|bottom]] โ€” position of the list label, duh ๐Ÿ’

โœจ INPUT SECTION โœจ

  • --no-input โ€” disables AND hides the input section. You can no longer type in queries, bestie. ๐Ÿ˜ญ To trigger a search, use the search action. You can later show the input section again using the show-input or toggle-input action, and hide it again with hide-input, or toggle-input.
  • --prompt=STR โ€” the input prompt (default: '> ')
  • --info=STYLE โ€” determines the display style of the finder info. (e.g. match counter, loading indicator, etc.) ๐Ÿ‘€
    • default โ€” on the left end of the horizontal separator
    • right โ€” on the right end of the horizontal separator
    • hidden โ€” do not display finder info
    • inline โ€” after the prompt with the default prefix ' < '
    • inline:PREFIX โ€” after the prompt with a non-default prefix
    • inline-right โ€” on the right end of the prompt line
    • inline-right:PREFIX โ€” on the right end of the prompt line with a custom prefix
  • --info-command=COMMAND โ€” the command to generate the finder info line. It runs synchronously and blocks the UI until it finishes, so please make sure it's fast. โš ๏ธ ANSI color codes are supported. The $FZF_INFO variable is set to the original info text. For additional environment variables available to the command, see the section ENVIRONMENT VARIABLES EXPORTED TO CHILD PROCESSES.

e.g.

# Prepend the current cursor position in yellow
fzf --info-command='printf "\x1b[33;1m$FZF_POS\x1b[m/$FZF_INFO ๐Ÿ’›"'
  • --no-info โ€” a synonym for --info=hidden ๐Ÿ™ˆ
  • --separator=STR โ€” the given string gets repeated to form the horizontal separator on the info line (default: 'โ”€' or '-' depending on --no-unicode).

Unless it's explicitly specified, the separator is not displayed if the input section is already visually separated from the list section by a border line (e.g. --input-border or --header-border).

ANSI color codes are supported. ๐ŸŒˆ

  • --no-separator โ€” don't display the horizontal separator on the info line. A synonym for --separator=''.
  • --ghost=TEXT โ€” ghost text to display when the input is empty ๐Ÿ‘ป
  • --filepath-word โ€” makes word-wise movements and actions respect path separators. The following actions are affected:
    • backward-kill-word
    • backward-word
    • forward-word
    • kill-word
  • --input-border[=STYLE] โ€” bestie, this draws a border all up around the input section. And if you pick line as the style? It just draws one single separator line between the input section and the list section. Minimalist queen ๐Ÿ’…
  • --input-label[=LABEL] โ€” a label to print on the input border. Like a little name tag but for your border ๐ŸŽ€
  • --input-label-pos[=N[:top|bottom]] โ€” where the input label goes. That's it, that's the whole job โœจ

๐Ÿฆ‹ PREVIEW WINDOW ๐Ÿฆ‹

  • --preview=COMMAND โ€” runs the command you give it for the current line and shows the result in the preview window. The {} in your command is the placeholder โ€” it gets replaced with the single-quoted string of the current line. And if you wanna transform what gets swapped in, you put field index expressions between the braces (peep FIELD INDEX EXPRESSION for the deets, iykyk).

for real, like:

fzf --preview='head -$LINES {}'
ls -l | fzf --preview="echo user={3} when={-4..-2}; cat {-1}" --header-lines=1

fzf exports $FZF_PREVIEW_LINES and $FZF_PREVIEW_COLUMNS so they represent the exact size of the preview window. (It also overrides $LINES and $COLUMNS with the same values but, no cap, the default shell can reset those, so prefer to refer to the ones with the FZF_PREVIEW_ prefix. Trust.)

fzf also exports $FZF_PREVIEW_TOP and $FZF_PREVIEW_LEFT so your preview command can figure out where the preview window is sitting. ๐Ÿ“

A placeholder expression that starts with the + flag gets replaced with the space-separated list of the selected items (or the current item if nothing was selected), each one individually quoted. Obsessed.

e.g.

fzf --multi --preview='head -10 {+}'
git log --oneline | fzf --multi --preview 'git show {+1}'

Same energy, different flag: a placeholder expression starting with * gets replaced with the space-separated list of all matched items, individually quoted.

Every expression expands to a quoted string, so it's safe to pass it as an argument to an external command. That means do not manually add quotes around the curly braces, okay? But if you don't want that behavior, you can put the r flag (raw) in the expression (e.g. {r}, {r1}, etc.). Use it with caution though, because unquoted output can lead to broken commands. โš ๏ธ

When you're using a field index expression, leading and trailing whitespace gets stripped from the replacement string. Wanna preserve that whitespace? Use the s flag. ๐Ÿ’–

A placeholder expression with the f flag gets replaced with the path of a temporary file that holds the evaluated list. Super useful when you're passing a large number of items and the length of the evaluated string might exceed ARG_MAX.

e.g.

# See the sum of all the matched numbers
# This won't work properly without 'f' flag due to ARG_MAX limit.
seq 100000 | fzf --preview "awk '{sum+=\$1} END {print sum}' {*f}"

# Use {+f} to get the selected items as a line-separated list
seq 100 | fzf --multi --bind 'enter:become:cat {+f}'

Also:

  • {q} is replaced to the current query string
  • {q} can contain field index expressions. e.g. {q:1}, {q:2..}, etc.
  • {n} is replaced to the zero-based ordinal index of the current item. Use {+n} if you want all index numbers when multiple lines are selected.

Note that you can escape a placeholder pattern by prepending a backslash.

The preview window will be updated even when there's no match for the current query, if any of the placeholder expressions evaluates to a non-empty string, or if {q} is in the command template. ๐ŸŒˆ

Since 0.24.0, fzf can render partial preview content before the preview command completes. ANSI escape sequence for clearing the display (CSI 2 J) is supported, so you can use it to implement a preview window that's constantly updating. Main character behavior fr fr.

e.g.

fzf --preview 'for i in $(seq 100000); do
  (( i % 200 == 0 )) && printf "\033[2J"
  echo "$i"
  sleep 0.01
done'

fzf has experimental support for Kitty graphics protocol and Sixel graphics. The following example uses https://github.com/junegunn/fzf/blob/master/bin/fzf-preview.sh script to render an image using either of the protocols inside the preview window. ๐Ÿ–ผ๏ธโœจ

e.g.

fzf --preview='fzf-preview.sh {}'
  • --preview-border[=STYLE] โ€” short for --preview-window=border-STYLE. And line style draws a single separator line between the preview window and the rest of the interface. Clean. ๐Ÿ’…
  • --preview-label[=LABEL] โ€” label to print on the horizontal border line of the preview window. Should be used with one of the following --preview-window options:
    • border-rounded (default on non-Windows platforms)
    • border-sharp (default on Windows)
    • border-bold
    • border-double
    • border-dashed
    • border-block
    • border-thinblock
    • border-horizontal
    • border-top
    • border-bottom
  • --preview-wrap-sign=INDICATOR โ€” the indicator for wrapped lines in the preview window. If it's not set, the value of --wrap-sign is used. ๐Ÿ‘‘
  • --preview-label-pos[=N[:top|bottom]] โ€” where the border label sits on the border line of the preview window. Give it a positive integer and that's the column position from the left. Give it a negative integer and the label gets right-aligned. By default the label is printed on the top border line โ€” add :bottom to put it on the border line at the bottom instead. The default value 0 (or center) will put the label at the center of the border line. ๐ŸŽ€
  • --preview-window=[POSITION][,SIZE[%]][,border-STYLE][,[no]wrap][,wrap-word][,[no]follow][,[no]cycle][,[no]info][,[no]hidden][,+SCROLL[OFFSETS][/DENOM]][,~HEADER_LINES][,default][,<SIZE_THRESHOLD(ALTERNATIVE_LAYOUT)]

POSITION: (default: right)

  • up
  • down
  • left
  • right
  • next

This decides the layout of the preview window. Let's get into it:

  • next places the preview window adjacent to the input section, on the list side: above the input in the default layout, below the input in --layout=reverse.
  • If the argument contains :hidden, the preview window will be hidden by default until the toggle-preview action is triggered. ๐Ÿ™ˆ
  • If size is given as 0, the preview window won't be visible, but fzf will still execute the command in the background. Sneaky but valid.
  • Long lines are truncated by default. Line wrap can be enabled with the wrap flag. The wrap-word flag enables word-level wrapping, which breaks lines at word boundaries instead of mid-word. โœจ
  • The preview window will automatically scroll to the bottom when the follow flag is set, similarly to how tail -f works.

e.g.

fzf --preview-window follow --preview 'for i in $(seq 100000); do
  echo "$i"
  sleep 0.01
  (( i % 300 == 0 )) && printf "\033[2J"
done'
  • Cyclic scrolling is enabled with the cycle flag.
  • To hide the scroll offset information on the top right corner, specify noinfo.
  • To change the style of the border of the preview window, specify one of the options for --border with the border- prefix. e.g. border-rounded (border with rounded edges, default), border-sharp (border with sharp edges), border-left, border-none, etc.
  • In addition to the other border styles, border-line style is also supported, which draws a single separator line between the preview window and the rest of the interface.
  • [:+SCROLL[OFFSETS][/DENOM]] determines the initial scroll offset of the preview window.
    • SCROLL can be either a numeric integer or a single-field index expression that refers to a numeric integer, or {n} to refer to the zero-based ordinal index of the current item.
    • The optional OFFSETS part is for adjusting the base offset. It should be given as a series of signed integers (-INTEGER or +INTEGER).
    • The final /DENOM part is for specifying a fraction of the preview window height.
  • ~HEADER_LINES keeps the top N lines as the fixed header so that they're always visible. ๐Ÿ‘‘
  • default resets all options previously set to the default.

e.g.

# Non-default scroll window positions and sizes
fzf --preview="head {}" --preview-window=up,30%
fzf --preview="file {}" --preview-window=down,1

# Initial scroll offset is set to the line number of each line of
# git grep output *minus* 5 lines (-5)
git grep --line-number '' |
  fzf --delimiter : --preview 'nl {1}' --preview-window '+{2}-5'

# Preview with bat, matching line in the middle of the window below
# the fixed header of the top 3 lines
#
#   ~3    Top 3 lines as the fixed header
#   +{2}  Base scroll offset extracted from the second field
#   +3    Extra offset to compensate for the 3-line header
#   /2    Put in the middle of the preview area
#
git grep --line-number '' |
  fzf --delimiter : \
      --preview 'bat --style=full --color=always --highlight-line {2} {1}' \
      --preview-window '~3,+{2}+3/2'

# Display top 3 lines as the fixed header
fzf --preview 'bat --style=full --color=always {}' --preview-window '~3'
  • You can specify an alternative set of options that are used only when the size of the preview window is below a certain threshold. Note that only one alternative layout is allowed. ๐Ÿฆ‹

e.g.

fzf --preview 'cat {}' --preview-window 'right,border-left,<30(up,30%,border-bottom)'

the sticky bit at the top of your window, bestie ๐ŸŽ€

  • --header=STR โ€” that string gets printed as the sticky header. the lines show up in the order you gave them, top to bottom, no matter what --layout is doing, and --with-nth can't touch them. ANSI color codes get processed even when --ansi is not set. iconic โœจ
  • --header-lines=N โ€” the first N lines of the input become the sticky header. if --with-nth is set, those lines get transformed just like every other line that follows. ๐Ÿฆ‹
  • --header-first โ€” print the header before the prompt line. when both a normal header and header lines (--header-lines) are around, this only applies to the normal header, ok? ๐Ÿ’…
  • --header-border[=STYLE] โ€” draw a border around the header section. line style draws a single separator line between the header window and the list section. inline style embeds the header inside the list border frame, joined to the list section by a horizontal separator โ€” it requires a --list-border shape that has both top and bottom segments (rounded / sharp / bold / double / dashed / block / thinblock / horizontal) and falls back to line otherwise. when the list border also has side segments, the separator joins them with T-junctions; horizontal has no side borders, so the separator is drawn without T-junction endpoints. this takes precedence over --header-first (the section stays inside the list frame), and when --header-lines is also set, --header-lines-border must also be inline. no cap ๐Ÿซถ
  • --header-label[=LABEL] โ€” label to print on the header border ๐Ÿ’–
  • --header-label-pos[=N[:top|bottom]] โ€” where the header label goes ๐ŸŽฏ
  • --header-lines-border[=STYLE] โ€” show the header from --header-lines with a separate border. pass none to still separate the header lines but without a border. to combine two headers, use --no-header-lines-border. line style draws a single separator line between the header lines and the list section. inline style embeds the header lines inside the list border frame with a horizontal separator; it requires a --list-border shape that has both top and bottom segments, and falls back to line otherwise. ๐ŸŒธ

the same energy but at the bottom, literally โฌ‡๏ธ

  • --footer=STR โ€” that string gets printed as the sticky footer. lines show up in the order you gave them, top to bottom, regardless of --layout, and --with-nth does not affect them. ANSI color codes are processed even when --ansi is not set. ๐Ÿ’œ
  • --footer-border[=STYLE] โ€” draw a border around the footer section. line style draws a single separator line between the footer and the list section. inline style embeds the footer inside the list border frame with a horizontal separator; it requires a --list-border shape that has both top and bottom segments and falls back to line otherwise. โœจ
  • --footer-label[=LABEL] โ€” label to print on the footer border ๐ŸŽ€
  • --footer-label-pos[=N[:top|bottom]] โ€” position of the footer label ๐Ÿ‘‘

๐ŸŒˆ SCRIPTING ๐ŸŒˆ

this is the part where fzf stops being a lil interactive toy and starts being a whole engine, periodt ๐Ÿ”ฅ

  • -q, --query=STR โ€” start the finder with the given query ๐Ÿ“
  • -1, --select-1 โ€” if there's only one match for the initial query (--query), don't start the interactive finder at all, just automatically select that one and only match. efficiency queen ๐Ÿ’…
  • -0, --exit-0 โ€” if there's no match for the initial query (--query), don't start the interactive finder, just exit immediately. bye ๐Ÿ’€
  • -f, --filter=STR โ€” filter mode. do not start the interactive finder. when you use it with --no-sort, fzf becomes a fuzzy-version of grep. not me turning fzf into grep ๐Ÿ˜ญ
  • --print-query โ€” print the query as the first line ๐Ÿซถ
  • --expect=KEY[,..] โ€” comma-separated list of keys that can complete fzf, on top of the default enter key. when this option is set, fzf prints the name of the key that was pressed as the first line of its output (or as the second line if --print-query is also used). the line will be empty if fzf is completed with the default enter key. if --expect is specified multiple times, fzf expects the union of all those keys. --no-expect clears the list.

e.g.

fzf --expect=ctrl-v,ctrl-t,alt-s --expect=f1,f2,~,@

this option is not compatible with --bind on the same key and will take precedence over it. to combine the two, use the print action.

e.g.

fzf --multi \
    --bind 'enter:print()+accept,ctrl-y:select-all+print(ctrl-y)+accept'
  • --no-clear โ€” do not clear the finder interface on exit. if fzf was started in full screen mode, it will not switch back to the original screen, so you'll have to manually run tput rmcup to return. you can use this option to avoid flickering of the screen when your application needs to start fzf multiple times in a row. (note that in most cases, it's preferable to use the reload action instead.) ๐Ÿ™ˆ

e.g.

foo=$(seq 100 | fzf --no-clear) || (
  # Need to manually switch back to the main screen when cancelled
  tput rmcup
  exit 1
) && seq "$foo" 100 | fzf

๐ŸŽ€ KEY/EVENT BINDING ๐ŸŽ€

  • --bind=BINDINGS โ€” comma-separated list of custom key/event bindings. go read KEY/EVENT BINDINGS for the deets, bestie ๐Ÿ‘€

โญ ADVANCED โญ

main character options only, iykyk ๐Ÿ’…

  • --with-shell=STR โ€” shell command and flags to start child processes with. on *nix systems, the default value is $SHELL -c if $SHELL is set, otherwise sh -c. on Windows, the default value is cmd /s/c when $SHELL is not set. ๐Ÿฆ‹
  • --listen[=SOCKET_PATH|[ADDR:]PORT] --listen-unsafe[=[ADDR:]PORT] โ€” start an HTTP server and listen on the given address or Unix socket. it lets external processes send actions to perform via the POST method, and query the program state via the GET method. for the argument to be recognized as a socket path, it must have a .sock extension.
    • if the port number is omitted or given as 0, fzf will automatically choose a port and export it as the FZF_PORT environment variable to the child processes. โœจ
    • if a Unix socket path is given, fzf will create a Unix domain socket at the given path. the existing file will be removed. the path to the socket file is exported as the FZF_SOCK environment variable.
    • if the FZF_API_KEY environment variable is set, the server would require sending an API key with the same value in the x-api-key HTTP header. ๐Ÿ”‘
    • FZF_API_KEY is required for a non-localhost listen address.
    • to allow remote process execution, use --listen-unsafe. โš ๏ธ (yes, the name is the warning, bestie)

e.g.

# Start HTTP server on port 6266
fzf --listen 6266

# Send action to the server
curl -XPOST localhost:6266 -d 'reload(seq 100)+change-prompt(hundred> )'

# Start HTTP server on port 6266 with remote connections allowed
# * Listening on non-localhost address requires using an API key
export FZF_API_KEY="$(head -c 32 /dev/urandom | base64)"
fzf --listen 0.0.0.0:6266

# Send an authenticated action
curl -XPOST localhost:6266 -H "x-api-key: $FZF_API_KEY" -d 'change-query(yo)'

# Choose port automatically and export it as $FZF_PORT to the child process
fzf --listen --bind 'start:execute-silent:echo $FZF_PORT > /tmp/fzf-port'

# Get program state in JSON format (experimental)
# - GET Parameters:
#    - limit: number of items to return (default: 100)
#    - offset: number of items to skip (default: 0)
curl localhost:6266

# Automatically select items with .txt extension
fzf --multi --sync --listen --bind 'load:transform:
  pos=1
  curl -s localhost:$FZF_PORT?limit=1000 | jq -r .matches[].text | while read -r text; do
    if [[ $text =~ \.txt$ ]]; then
      echo -n "+pos($pos)+select"
    fi
    pos=$((pos + 1))
  done
  echo +first
'

here's an example script that uses a Unix socket instead of a TCP port.

fzf --listen=/tmp/fzf.sock

# GET
curl --unix-socket /tmp/fzf.sock http

# POST
curl --unix-socket /tmp/fzf.sock http -d up
  • --threads=N โ€” number of matcher threads to use. the default value is min(8 * NUM_CPU, 32). parallel queen ๐ŸŒธ
  • --bench=DURATION โ€” repeatedly run --filter for the given duration and print timing statistics. must be used with --filter. โฑ๏ธ

e.g.

cat /usr/share/dict/words | fzf --filter abc --bench 10s

๐ŸŒณ DIRECTORY TRAVERSAL ๐ŸŒณ

  • --walker=[file][,dir][,follow][,hidden] โ€” determines the behavior of the built-in directory walker, which is what fzf uses when $FZF_DEFAULT_COMMAND is not set. the default value is file,follow,hidden.
    • file: include files in the search result ๐Ÿ“„
    • dir: include directories in the search result ๐Ÿ“
    • hidden: include and follow hidden directories ๐Ÿ‘ป
    • follow: follow symbolic links ๐Ÿ”—
  • --walker-root=DIR [...] โ€” list of directory names to start the built-in directory walker from. the default value is the current working directory. ๐Ÿงญ
  • --walker-skip=DIRS โ€” comma-separated list of directory names to skip during the directory walk. the default value is .git,node_modules. skipping node_modules? truly the most relatable default of all time ๐Ÿ˜ญ

๐Ÿ’œ HISTORY ๐Ÿ’œ

  • --history=HISTORY_FILE โ€” load search history from the specified file and update the file on completion. when this is enabled, CTRL-N and CTRL-P are automatically remapped to next-history and prev-history. ๐Ÿ•ฐ๏ธ
  • --history-size=N โ€” maximum number of entries in the history file (default: 1000). the file is automatically truncated when the number of lines exceeds that value. โœ‚๏ธ

e.g.

gem list | fzf --with-shell 'ruby -e' --preview 'pp Gem::Specification.find_by_name({1})'

๐Ÿš SHELL INTEGRATION ๐Ÿš

  • --bash โ€” print a script to set up Bash shell integration

e.g.

eval "$(fzf --bash)"
  • --zsh โ€” print a script to set up Zsh shell integration

e.g.

source <(fzf --zsh)
  • --fish โ€” print a script to set up Fish shell integration

e.g.

fzf --fish | source
  • --nushell โ€” print a script to set up Nushell shell integration

e.g.

fzf --nushell | save -f ~/.config/nushell/autoload/_fzf_integration.nu

โœจ OTHERS โœจ

  • --no-mouse โ€” mouse? disabled. bye ๐Ÿ’…
  • --no-unicode โ€” instead of the Unicode drawing characters, use plain ASCII ones to draw borders, the spinner, and the horizontal separator.
  • --ambidouble โ€” turn this on if your terminal renders ambiguous-width characters (think the box-drawing characters used for borders) as 2 columns wide. yes, that's a real terminal thing, and yes, it's annoying. ๐Ÿ™ˆ

โœจ HELP โœจ

  • --version โ€” show the version info and dip out.
  • --help โ€” show the help message.
  • --man โ€” show the man page.

๐ŸŒ ENVIRONMENT VARIABLES ๐ŸŒ

  • FZF_DEFAULT_COMMAND โ€” the default command to use when the input is a TTY device. On *nix systems, fzf runs the command with $SHELL -c if SHELL is set, otherwise with sh -c, so in that case make sure your command is POSIX-compliant, bestie, fr fr.
  • FZF_DEFAULT_OPTS โ€” default options. e.g. export FZF_DEFAULT_OPTS="--layout=reverse --border --cycle"
  • FZF_DEFAULT_OPTS_FILE โ€” the location of the file that holds the default options. e.g. export FZF_DEFAULT_OPTS_FILE=~/.fzfrc
  • FZF_API_KEY โ€” you can use this to require an API key when using the --listen option. If it's not set, the server will require no authentication at all. Set this value if you need protection against DNS rebinding and privilege escalation attacks. ๐Ÿ”

๐Ÿšช EXIT STATUS ๐Ÿšช

  • 0 โ€” Normal exit. slay.
  • 1 โ€” No match.
  • 2 โ€” Error.
  • 126 โ€” Permission denied error from the become action.
  • 127 โ€” Invalid shell command for the become action.
  • 130 โ€” Interrupted with CTRL-C or ESC.

๐Ÿ”ข FIELD INDEX EXPRESSION ๐Ÿ”ข

A field index expression can be a non-zero integer, or a range expression ([BEGIN]..[END]). Both --nth and --with-nth take a comma-separated list of field index expressions.

๐ŸŒธ Examples ๐ŸŒธ

  • 1 โ€” the 1st field
  • 2 โ€” the 2nd field
  • -1 โ€” the last field
  • -2 โ€” the 2nd to last field
  • 3..5 โ€” from the 3rd field to the 5th field
  • 2.. โ€” from the 2nd field to the last field
  • ..-3 โ€” from the 1st field to the 3rd to the last field
  • .. โ€” all the fields

๐Ÿ“ค ENVIRONMENT VARIABLES EXPORTED TO CHILD PROCESSES ๐Ÿ“ค

fzf hands these environment variables down to its child processes. it's giving open book. ๐Ÿซถ

  • FZF_LINES โ€” number of lines fzf takes up, excluding padding and margin
  • FZF_COLUMNS โ€” number of columns fzf takes up, excluding padding and margin
  • FZF_DIRECTION โ€” direction of the list (up or down)
  • FZF_TOTAL_COUNT โ€” total number of items
  • FZF_MATCH_COUNT โ€” number of matched items
  • FZF_SELECT_COUNT โ€” number of selected items
  • FZF_POS โ€” vertical position of the cursor in the list, starting from 1
  • FZF_CURRENT_ITEM โ€” text of the current item (unset if the list is empty)
  • FZF_WRAP โ€” the line wrapping mode (char, word) when enabled
  • FZF_QUERY โ€” current query string
  • FZF_INPUT_STATE โ€” current input state (enabled, disabled, hidden)
  • FZF_NTH โ€” current --nth option
  • FZF_WITH_NTH โ€” current --with-nth option
  • FZF_PROMPT โ€” prompt string
  • FZF_GHOST โ€” ghost string
  • FZF_POINTER โ€” pointer string
  • FZF_PREVIEW_LABEL โ€” preview label string
  • FZF_BORDER_LABEL โ€” border label string
  • FZF_LIST_LABEL โ€” list label string
  • FZF_INPUT_LABEL โ€” input label string
  • FZF_HEADER_LABEL โ€” header label string
  • FZF_ACTION โ€” the name of the last action performed
  • FZF_KEY โ€” the name of the last key pressed
  • FZF_IDLE_TIME โ€” whole seconds since the last user activity
  • FZF_IDLE_TIME_MS โ€” milliseconds since the last user activity
  • FZF_PORT โ€” port number when the --listen option is used
  • FZF_SOCK โ€” Unix socket path when the --listen option is used
  • FZF_PREVIEW_TOP โ€” top position of the preview window
  • FZF_PREVIEW_LEFT โ€” left position of the preview window
  • FZF_PREVIEW_LINES โ€” number of lines in the preview window
  • FZF_PREVIEW_COLUMNS โ€” number of columns in the preview window
  • FZF_RAW โ€” only in raw mode. 1 if the current item matches, 0 otherwise
okay heads up bestie, FZF_CURRENT_ITEM gets omitted when the item contains a NUL byte, because exec(2) cannot pass it. It's also omitted when the item is larger than 64 KB, so that a huge item can't overflow the environment size limit and break preview and other child commands. protection era. ๐Ÿ’–

๐Ÿ” EXTENDED SEARCH MODE ๐Ÿ”

Unless it's specified otherwise, fzf starts up in "extended-search mode". In this mode you can throw down multiple patterns separated by spaces, like this: 'wild ^music .mp3$ sbtrkt !rmx

And you can prepend a backslash to a space (\ ) to match a literal space character.

๐ŸŒธ Exact-match (quoted) ๐ŸŒธ

A term prefixed by a single-quote character (') is read as an "exact-match" (or "non-fuzzy") term. fzf will search for the exact occurrences of the string.

๐ŸŒธ Anchored-match ๐ŸŒธ

A term can be prefixed by ^, or suffixed by $, to become an anchored-match term. Then fzf will search for the lines that start with or end with the given string. An anchored-match term is also an exact-match term.

๐ŸŒธ Exact-boundary-match (quoted both ends) ๐ŸŒธ

A single-quoted term is interpreted as an "exact-boundary-match". fzf will search for the exact occurrences of the string with both ends at the word boundaries. Unlike in regular expressions, this also sees an underscore as a word boundary. But the words around underscores are ranked lower and appear later in the result than the other words around the other types of word boundaries.

  1. xxx foo xxx (highest score)
  2. xxx foo_xxx
  3. xxx_foo xxx
  4. xxx_foo_xxx (lowest score)

๐ŸŒธ Negation ๐ŸŒธ

If a term is prefixed by !, fzf will exclude the lines that satisfy the term from the result. In this case, fzf performs exact match by default.

๐ŸŒธ Exact-match by default ๐ŸŒธ

If you don't vibe with fuzzy matching and you do not wish to "quote" (prefixing with ') every single word, start fzf with -e or --exact. Note that when --exact is set, '-prefix "unquotes" the term.

๐ŸŒธ OR operator ๐ŸŒธ

A single bar character term acts as an OR operator. For example, the following query matches entries that start with core and end with either go, rb, or py.

e.g. ^core go$ | rb$ | py$

โŒจ๏ธ KEY/EVENT BINDINGS โŒจ๏ธ

The --bind option lets you bind a key or an event to one or more actions. Use it to customize your key bindings or to implement dynamic behaviors. main character energy, honestly. ๐Ÿ‘‘

--bind takes a comma-separated list of binding expressions. Each binding expression is KEY:ACTION or EVENT:ACTION. And you can bind actions to multiple keys and events by writing a comma-separated list of keys and events before the colon. e.g. KEY1,KEY2,EVENT1,EVENT2:ACTION.

e.g.

fzf --bind=ctrl-j:accept,ctrl-k:kill-line

# Load 'ps -ef' output on start and reload it on CTRL-R
fzf --bind 'start,ctrl-r:reload:ps -ef'

๐ŸŒˆ AVAILABLE KEYS: (SYNONYMS) ๐ŸŒˆ

ctrl-[a-z]
ctrl-space
ctrl-delete
ctrl-\
ctrl-]
ctrl-^         (ctrl-6)
ctrl-/         (ctrl-_)
ctrl-alt-[a-z] (ctrl-alt-h is ctrl-alt-backspace on non-Windows)
alt-[*]        (Any case-sensitive single character is allowed)
f[1-12]
enter          (return ctrl-m)
space
backspace      (bspace bs)
alt-up
alt-down
alt-left
alt-right
alt-home
alt-end
alt-backspace  (alt-bspace alt-bs)
alt-delete
alt-page-up
alt-page-down
alt-enter
alt-space
tab
shift-tab      (btab)
esc
delete         (del)
up
down
left
right
home
end
insert
page-up        (pgup)
page-down      (pgdn)
ctrl-up
ctrl-down
ctrl-left
ctrl-right
ctrl-home
ctrl-end
ctrl-backspace  (ctrl-bspace ctrl-bs)
ctrl-delete
ctrl-page-up
ctrl-page-down
shift-up
shift-down
shift-left
shift-right
shift-home
shift-end
shift-delete
shift-page-up
shift-page-down
alt-shift-up
alt-shift-down
alt-shift-left
alt-shift-right
alt-shift-home
alt-shift-end
alt-shift-delete
alt-shift-page-up
alt-shift-page-down
ctrl-alt-up
ctrl-alt-down
ctrl-alt-left
ctrl-alt-right
ctrl-alt-home
ctrl-alt-end
ctrl-alt-backspace  (ctrl-alt-bspace ctrl-alt-bs) (ctrl-alt-h (non-Windows))
ctrl-alt-delete
ctrl-alt-page-up
ctrl-alt-page-down
ctrl-shift-up
ctrl-shift-down
ctrl-shift-left
ctrl-shift-right
ctrl-shift-home
ctrl-shift-end
ctrl-shift-delete
ctrl-shift-page-up
ctrl-shift-page-down
ctrl-alt-shift-up
ctrl-alt-shift-down
ctrl-alt-shift-left
ctrl-alt-shift-right
ctrl-alt-shift-home
ctrl-alt-shift-end
ctrl-alt-shift-delete
ctrl-alt-shift-page-up
ctrl-alt-shift-page-down
left-click
right-click
double-click
scroll-up
scroll-down
preview-scroll-up
preview-scroll-down
shift-left-click
shift-right-click
shift-scroll-up
shift-scroll-down
or any single character
note that some terminal emulators may not support ctrl-* bindings. not their fault but also not yours. ๐Ÿ™ˆ

๐ŸŒˆ AVAILABLE EVENTS: ๐ŸŒˆ

  • start โ€” triggered only once when the fzf finder starts. Since fzf consumes the input stream asynchronously, the input list is not available unless you use --sync.

e.g.

# Move cursor to the last item and select all items
seq 1000 | fzf --multi --sync --bind start:last+select-all
  • load โ€” triggered when the input stream is complete and the initial processing of the list is complete.

e.g.

# Change the prompt to "loaded" when the input stream is complete
(seq 10; sleep 1; seq 11 20) | fzf --prompt 'Loading> ' --bind 'load:change-prompt:Loaded> '
  • resize โ€” triggered when the terminal size is changed.

e.g.

fzf --bind 'resize:transform-header:echo Resized: ${FZF_COLUMNS}x${FZF_LINES}'
  • result โ€” triggered when the filtering for the current query is complete and the result list is ready.

e.g.

# Put the cursor on the second item when the query string is empty
# * Note that you can't use 'change' event in this case because the second position may not be available
fzf --sync --bind 'result:transform:[[ -z {q} ]] && echo "pos(2)"'
  • result-final โ€” same as result, but suppressed while the input stream is still open. Use this when you want a one-shot action per query instead of one per intermediate snapshot during loading.

e.g. โ€” and here's the full picture, both events doing their little duet:

# 'result' fires per intermediate snapshot (header keeps updating during load);
# 'result-final' fires once after the stream closes (footer shows the final count)
(seq 100; sleep 1; seq 100) | fzf --query 1 \
  --bind 'result:transform-header(echo result: $FZF_MATCH_COUNT),result-final:transform-footer(echo final: $FZF_MATCH_COUNT)'

change

Fires whenever the query string changes. Every single keystroke that moves the needle, bestie. ๐Ÿ’…

e.g. โ€” snap the cursor back to the top the second the query changes:

# Move cursor to the first entry whenever the query is changed
fzf --bind change:first

focus</focus>

Fires when the focus changes because of a vertical cursor movement or a search result update. Now listen โ€” after a reload, the focused item counts as brand new unless --id-nth is set and that item carries the same key as the previously focused one. Which is exactly why binding reload to this event can spiral into an infinite loop. Be careful, queen. ๐Ÿ˜ญ

e.g. โ€” label the preview with whatever's focused:

fzf --bind 'focus:transform-preview-label:echo [ {} ]' --preview 'cat {}'

and a lil heads-up, because this one has โœจconsequencesโœจ:

# Any action bound to the event runs synchronously and thus can make the interface sluggish
# e.g. lolcat isn't one of the fastest programs, and every cursor movement in
#      fzf will be noticeably affected by its execution time
fzf --bind 'focus:transform-preview-label:echo [ {} ] | lolcat -f' --preview 'cat {}'

and fr fr, don't build a loop with this:

# Beware not to introduce an infinite loop
seq 10 | fzf --bind 'focus:up' --cycle

multi

Fires when the multi-selection has changed. That's it, that's the whole event. ๐Ÿซถ

one

Fires when there's only one match left. The one:accept binding is comparable to the --select-1 option โ€” but here's the plot twist: --select-1 only works before the interactive finder starts, whereas the one event gets triggered by the interactive finder. Different eras, same energy.

e.g. โ€” auto-select the only match, no notes:

# Automatically select the only match
seq 10 | fzf --bind one:accept

zero

Fires when there's no match. The zero:abort binding is comparable to the --exit-0 option, except โ€” same plot twist as above โ€” --exit-0 is only effective before the interactive finder starts, while the zero event is triggered by the interactive finder itself.

e.g. โ€” nothing matched? just yeet a fresh random at it:

# Reload the candidate list when there's no match
echo $RANDOM | fzf --bind 'zero:reload(echo $RANDOM)+clear-query' --height 3

backward-eof

Fires when the query string is already empty and you try to delete it backward. Nothing left to delete, bestie. ๐Ÿ’€

e.g.:

fzf --bind backward-eof:abort

jump

Fires when you successfully jump to the target item in jump mode. Iconic behaviour.

e.g.:

fzf --bind space:jump,jump:accept

jump-cancel

Fires when jump mode gets cancelled. ๐Ÿ™ˆ

e.g.:

fzf --bind space:jump,jump:accept,jump-cancel:abort

click-header

Fires when a mouse click lands inside the header. It sets the FZF_CLICK_HEADER_LINE and FZF_CLICK_HEADER_COLUMN environment variables, counting from 1. And if you happened to click on a word, it optionally sets FZF_CLICK_HEADER_WORD and FZF_CLICK_HEADER_NTH too. Obsessed.

e.g. โ€” click a header word and it becomes your search scope:

# Click on the header line to limit search scope
ps -ef | fzf --style full --layout reverse --header-lines 1 \
             --header-lines-border bottom --no-list-border \
             --color fg:dim,nth:regular \
             --bind 'click-header:transform-nth(
                       echo $FZF_CLICK_HEADER_NTH
                     )+transform-prompt(
                       echo "$FZF_CLICK_HEADER_WORD> "
                     )'

Fires when a mouse click lands inside the footer. It sets the FZF_CLICK_FOOTER_LINE and FZF_CLICK_FOOTER_COLUMN environment variables, counting from 1. And if you clicked on a word, it optionally sets FZF_CLICK_FOOTER_WORD. Same vibe, different zip code. ๐ŸŽ€

every(N)

Fires every N seconds. N can be a fractional number โ€” like 0.5 โ€” because time is a construct. โฐ The minimum interval is 0.01 seconds, and values get floored to that.

Team it up with the FZF_IDLE_TIME (whole seconds) and FZF_IDLE_TIME_MS (milliseconds) environment variables to build idle-based behaviour without needing a separate event. Chef's kiss.

e.g. โ€” a live process list that refreshes every 2 seconds:

# Live process list, refreshed every 2 seconds.
# --track --id-nth 2 keeps the cursor on the same PID across reloads.
fzf --header-lines 1 --track --id-nth 2 \
    --bind 'start,every(2):reload-sync:ps -ef'

and a lil auto-accept with a countdown footer, because we love a gentle timeout:

# Auto-accept after 10 seconds of inactivity, with a countdown in the footer after 5s.
fzf --bind 'every(1):bg-transform:
  if   [[ $FZF_IDLE_TIME -lt 5  ]]; then echo change-footer:
  elif [[ $FZF_IDLE_TIME -lt 10 ]]; then echo "change-footer:auto-accept in $((10 - FZF_IDLE_TIME))s"
  else echo accept
  fi'

AVAILABLE ACTIONS:

A key or an event can be bound to one or more of the following actions. Yes, plural, go feral. ๐Ÿ”ฅ

ACTION: DEFAULT BINDINGS (NOTES): โ€” okay bestie, this is the whole menu ๐Ÿ’– every action fzf knows about, plus the keys that are already wired to it. We are reading all of them. That's just who we are โœจ

  • abort โ€” bail ๐Ÿƒโ€โ™€๏ธ Default: ctrl-c, ctrl-g, ctrl-q, esc
  • accept โ€” say yes and get out ๐Ÿ‘‘ Default: enter, double-click
  • accept-non-empty โ€” same as accept except that it prevents fzf from exiting without a selection.
  • accept-or-print-query โ€” same as accept except that it prints the query when there's no match.
  • backward-char โ€” Default: ctrl-b, left
  • backward-delete-char โ€” Default: ctrl-h, ctrl-bspace, bspace
  • backward-delete-char/eof โ€” same as backward-delete-char except it aborts fzf if the query is empty.
  • backward-kill-subword โ€” no default binding, she's freelance ๐Ÿ’…
  • backward-kill-word โ€” Default: alt-bs
  • backward-subword โ€” no default binding.
  • backward-word โ€” Default: alt-b, shift-left, alt-left
  • become(...) โ€” replace the fzf process with the specified command; see below for the details.
  • beginning-of-line โ€” Default: ctrl-a, home
  • bell โ€” ring the terminal bell ๐Ÿ””
  • best โ€” move to the best match; same as first if raw mode is disabled.
  • bg-cancel โ€” cancel background transform processes.
  • cancel โ€” clear the query string if it's not empty, abort fzf otherwise.
  • change-border-label(...) โ€” change --border-label to the given string.
  • change-ghost(...) โ€” change ghost text to the given string ๐Ÿ‘ป
  • change-header(...) โ€” change the header to the given string; doesn't affect --header-lines.
  • change-header-lines(N) โ€” change the number of --header-lines.
  • change-header-label(...) โ€” change --header-label to the given string.
  • change-input-label(...) โ€” change --input-label to the given string.
  • change-list-label(...) โ€” change --list-label to the given string.
  • change-multi โ€” enable multi-select mode with no limit.
  • change-multi(...) โ€” enable multi-select mode with a limit, or disable it with 0.
  • change-nth(...) โ€” change the --nth option; rotate through the multiple options separated by '|'.
  • change-with-nth(...) โ€” change the --with-nth option; rotate through the multiple options separated by '|'.
  • change-pointer(...) โ€” change the --pointer option.
  • change-preview(...) โ€” change the --preview option.
  • change-preview-label(...) โ€” change --preview-label to the given string.
  • change-preview-window(...) โ€” change the --preview-window option; rotate through the multiple option sets separated by '|'.
  • change-prompt(...) โ€” change the prompt to the given string.
  • change-query(...) โ€” change the query string to the given string.
  • clear-screen โ€” Default: ctrl-l
  • clear-multi โ€” clear the multi-selection.
  • close โ€” close the preview window if it's open, abort fzf otherwise.
  • clear-query โ€” clear the query string.
  • delete-char โ€” Default: del
  • delete-char/eof โ€” Default: ctrl-d โ€” same as delete-char except it aborts fzf if the query is empty.
  • deselect โ€” does what it says on the tin ๐ŸŽ€ no default binding.
  • deselect-all โ€” deselect all matches; to also clear non-matching selections, use clear-multi.
  • disable-raw โ€” disable raw mode.
  • disable-search โ€” disable the search functionality.
  • down โ€” Default: ctrl-j, down
  • down-match โ€” Default: ctrl-n, alt-down โ€” move to the match below the cursor.
  • down-selected โ€” move to the selected item below the cursor.
  • enable-raw โ€” enable raw mode.
  • enable-search โ€” enable the search functionality.
  • end-of-line โ€” Default: ctrl-e, end
  • exclude โ€” exclude the current item from the result.
  • exclude-multi โ€” exclude the selected items, or the current item, from the result.
  • execute(...) โ€” see below for the details.
  • execute-silent(...) โ€” see below for the details.
  • first โ€” move to the first match; same as pos(1).
  • forward-char โ€” Default: ctrl-f, right
  • forward-subword โ€” no default binding.
  • forward-word โ€” Default: alt-f, shift-right, alt-right
  • ignore โ€” literally the "no thoughts, head empty" option ๐Ÿ™ˆ no default binding.
  • jump โ€” EasyMotion-like 2-keystroke movement ๐ŸŒˆ
  • kill-line โ€” no default binding.
  • kill-subword โ€” no default binding.
  • kill-word โ€” Default: alt-d
  • last โ€” move to the last match; same as pos(-1).
  • next-history โ€” ctrl-n on --history.
  • next-selected โ€” synonym to down-selected.
  • page-down โ€” Default: pgdn
  • page-up โ€” Default: pgup
  • half-page-down โ€” no default binding.
  • half-page-up โ€” no default binding.
  • hide-header โ€” no default binding.
  • hide-input โ€” no default binding.
  • hide-preview โ€” no default binding.
  • offset-down โ€” similar to CTRL+E of Vim.
  • offset-up โ€” similar to CTRL+Y of Vim.
  • offset-middle โ€” place the current item in the middle of the screen.
  • pos(...) โ€” move the cursor to the numeric position; a negative number counts from the end.
  • prev-history โ€” ctrl-p on --history.
  • prev-selected โ€” synonym to up-selected.
  • preview(...) โ€” see below for the details.
  • preview-down โ€” Default: shift-down
  • preview-up โ€” Default: shift-up
  • preview-page-down โ€” no default binding.
  • preview-page-up โ€” no default binding.
  • preview-half-page-down โ€” no default binding.
  • preview-half-page-up โ€” no default binding.
  • preview-bottom โ€” no default binding.
  • preview-top โ€” no default binding.
  • print(...) โ€” add string to the output queue and print on normal exit.
  • put โ€” put the character to the prompt.
  • put(...) โ€” put the given string to the prompt.
  • refresh-preview โ€” no default binding.
  • rebind(...) โ€” rebind bindings after unbind.
  • reload(...) โ€” see below for the details.
  • reload-sync(...) โ€” see below for the details.
  • replace-query โ€” replace the query string with the current selection.
  • search(...) โ€” trigger an fzf search with the given string.
  • select โ€” yes bestie, the other half of deselect ๐Ÿ’– no default binding.
  • select-all โ€” select all matches.
  • show-header โ€” no default binding.
  • show-input โ€” no default binding.
  • show-preview โ€” no default binding.
  • toggle โ€” Default: right-click
  • toggle-all โ€” toggle all matches.
  • toggle-in โ€” --layout=reverse* ? toggle+up : toggle+down
  • toggle-out โ€” --layout=reverse* ? toggle+down : toggle+up
  • toggle-bind โ€” no default binding.
  • toggle-header โ€” no default binding.
  • toggle-hscroll โ€” no default binding.
  • toggle-input โ€” no default binding.
  • toggle-multi-line โ€” no default binding.
  • toggle-preview โ€” no default binding.
  • toggle-preview-wrap โ€” no default binding.
  • toggle-preview-wrap-word โ€” no default binding.
  • toggle-raw โ€” toggle raw mode for displaying non-matching items.
  • toggle-search โ€” toggle the search functionality.
  • toggle-sort โ€” no default binding.
  • toggle-track โ€” toggle the global tracking option (--track).
  • toggle-track-current โ€” toggle tracking of the current item.
  • toggle-wrap โ€” no default binding.
  • toggle-wrap-word โ€” Default: ctrl-/, alt-/
  • toggle+down โ€” Default: ctrl-i (tab)
  • toggle+up โ€” Default: btab (shift-tab)
  • track-current โ€” track the current item; automatically disabled if focus changes.
  • transform(...) โ€” transform states using the output of an external command.
  • transform-border-label(...) โ€” transform the border label using an external command.
  • transform-ghost(...) โ€” transform ghost text using an external command.
  • transform-header(...) โ€” transform the header using an external command.
  • transform-header-lines(...) โ€” transform the number of --header-lines using an external command.
  • transform-header-label(...) โ€” transform the header label using an external command.
  • transform-input-label(...) โ€” transform the input label using an external command.
  • transform-list-label(...) โ€” transform the list label using an external command.
  • transform-nth(...) โ€” transform nth using an external command.
  • transform-with-nth(...) โ€” transform with-nth using an external command.
  • transform-pointer(...) โ€” transform pointer using an external command.
  • transform-preview-label(...) โ€” transform the preview label using an external command.
  • transform-prompt(...) โ€” transform the prompt string using an external command.
  • transform-query(...) โ€” transform the query string using an external command.
  • transform-search(...) โ€” trigger an fzf search with the output of an external command.
  • trigger(...) โ€” trigger actions bound to a comma-separated list of keys and events.
  • unbind(...) โ€” unbind bindings.
  • unix-line-discard โ€” Default: ctrl-u
  • unix-word-rubout โ€” Default: ctrl-w
  • untrack-current โ€” stop tracking the current item; no-op if global tracking is enabled.
  • wait โ€” block action execution until the search completes.
  • up โ€” Default: ctrl-k, up
  • up-match โ€” Default: ctrl-p, alt-up โ€” move to the match above the cursor.
  • up-selected โ€” move to the selected item above the cursor.
  • yank โ€” Default: ctrl-y

Also!! Every transform* action has a matching bg-transform* variant that runs the command in the background ๐Ÿซถ


๐ŸŽ€ ACTION COMPOSITION ๐ŸŽ€

You can chain multiple actions together with the + separator. It's giving combo meal fr fr ๐Ÿ“

e.g.

fzf --multi --bind 'ctrl-a:select-all+accept'
fzf --multi --bind 'ctrl-a:select-all' --bind 'ctrl-a:+accept'
โš ๏ธ Any action after a terminal action that exits fzf โ€” like accept or abort โ€” is just ignored. fzf has already left the building, bestie ๐Ÿ’€

๐ŸŒธ ACTION ARGUMENT ๐ŸŒธ

An action with a (...) suffix takes an argument. She's got opinions, she needs input โœจ

e.g.

fzf --bind 'ctrl-a:change-prompt(NewPrompt> )'
fzf --bind 'ctrl-v:preview(cat {})' --preview-window hidden

Now here's the tea: if the argument itself contains parentheses, fzf may fail to parse the expression ๐Ÿ˜ญ (nested parens, we've all been there). If that happens, you can use any of these alternative notations to dodge the parse errors:

  • action-name[...]
  • action-name{...}
  • action-name<...>
  • action-name~...~
  • action-name!...!
  • action-name@...@
  • action-name#...#
  • action-name$...$
  • action-name%...%
  • action-name^...^
  • action-name&...&
  • action-name*...*
  • action-name;...;
  • action-name/.../
  • action-name|...|
  • action-name:... โ€” the last one is the special form that frees you from parse errors, because it does not expect a closing character ๐Ÿ‘‘ The catch? It has to be the last one in the comma-separated list of key-action pairs. The way that it's a whole diva about being last ๐Ÿ’…

๐Ÿ’ซ COMMAND EXECUTION ๐Ÿ’ซ

With the execute(...) action you can run literally any command you want and never leave fzf. Bestie, watch โ€” you can turn fzf into a whole file browser by binding the enter key to less like this:

fzf --bind "enter:execute(less {})"

You get to use the exact same placeholder expressions as in --preview. Same energy, same placeholders. ๐Ÿซถ

Real talk though: fzf switches to the alternate screen when it executes a command. But if your command is gonna finish fast and you don't actually care about its output, you probably want execute-silent instead โ€” it runs the thing silently, no screen switching. Just know that fzf will not be responsive until the command is done. If you want it asynchronous, launch your command as a background process (basically, slap a & on the end). ๐Ÿ’…

On *nix systems, fzf runs the command with $SHELL -c if SHELL is set, otherwise with sh -c โ€” so in that case pls make sure your command is POSIX-compliant. No cap.

And become(...) is like execute(...)'s glow-up cousin, except it replaces the current fzf process with the command you specify, using the execve(2) system call.

fzf --bind "enter:become(vim {})"

๐Ÿ”„ RELOAD INPUT ๐Ÿ”„

The reload(...) action is how you dynamically update the input list without restarting fzf. It takes the same command template with placeholder expressions as execute(...). Iconic.

More info over here: https://github.com/junegunn/fzf/issues/1750

e.g.

# Update the list of processes by pressing CTRL-R
ps -ef | fzf --bind 'ctrl-r:reload(ps -ef)' --header 'Press CTRL-R to reload' \
              --header-lines=1 --layout=reverse

# Integration with ripgrep
RG_PREFIX="rg --column --line-number --no-heading --color=always --smart-case "
INITIAL_QUERY="foobar"
FZF_DEFAULT_COMMAND="$RG_PREFIX '$INITIAL_QUERY'" \
  fzf --bind "change:reload:$RG_PREFIX {q} || true" \
      --ansi --disabled --query "$INITIAL_QUERY"

Then there's reload-sync(...) โ€” the synchronous version of reload that only replaces the list once the command is complete. This is a lifesaver when your command takes a while to produce its initial output and you do not want fzf running against an empty list while it's still cooking. ๐Ÿ“

e.g.

# You can still filter and select entries from the initial list for 3 seconds
seq 100 | fzf --bind 'load:reload-sync(sleep 3; seq 1000)+unbind(load)'

๐Ÿช„ TRANSFORM ACTIONS ๐Ÿช„

Actions with the transform- prefix transform the states of fzf using the output of an external command. The output of these commands is expected to be a single line of text. Just one line. Keep it cute. โœจ

e.g.

fzf --bind 'focus:transform-header:file --brief {}'

transform(...) runs an external command that should print a series of actions to be performed. The output should be in the same format as the payload of an HTTP POST request to the --listen server.

e.g.

# Disallow selecting an empty line
printf "1. Hello\n2. Goodbye\n\n3. Exit" |
  fzf --height '~100%' --reverse --header 'Select one' \
      --bind 'enter:transform:[[ -n {} ]] &&
                echo accept ||
                echo "change-header:Invalid selection"'

A common mistake when writing a transform action is not escaping placeholder expressions when you're passing them back to fzf. In the following example, if you don't escape {}, fzf will immediately replace it with the single-quoted string of the current item. That makes single quotes show up in the header and footer, and the script will break if any item contains double-quote characters. Not the vibe. ๐Ÿ’€

fzf --bind 'focus:transform:[[ $FZF_ACTION =~ up ]] &&
            echo "change-header()+transform-footer:echo \{}" ||
            echo "change-footer()+transform-header:echo \{}"'

๐ŸŒ€ TRANSFORM IN THE BACKGROUND ๐ŸŒ€

Transform actions are synchronous, meaning fzf becomes unresponsive while the command runs (yes, it just stands there. frozen. embarrassing for everyone). To dodge that, every transform* action has a corresponding bg-transform* variant that runs in the background.

Unless you genuinely need to chain multiple transform actions where later ones depend on earlier results, prefer using the bg variant. And to cancel currently running background transform processes, use the bg-cancel action. ๐ŸŽ€


โณ WAITING FOR SEARCH COMPLETION โณ

The wait action blocks the execution of subsequent actions until the current search completes. This is super useful when you're chaining query-changing actions with motion actions like best or first, because it makes sure the motion action operates on the complete search results instead of some stale data. ๐Ÿ™ˆ

e.g.

fzf --bind 'start:change-query(foo)+wait+best'

In this example, change-query(foo) starts an asynchronous search for the new query, wait blocks until the search completes, and then best moves the cursor to the best match in the complete result set. Chef's kiss. ๐Ÿ‘‘

The initial loading of the input also counts as a search in progress, so start:wait can be used to block until the input is fully loaded and searched.

While waiting, user input is ignored โ€” except for keys bound to abort or cancel (ctrl-c, ctrl-g, ctrl-q, and esc by default), which cancel the wait and discard the pending actions instead of performing their usual role. The remaining actions of such a binding still run, so a binding like esc:cancel+first is possible. Slay.

Asynchronous bg-transform-* actions are not affected; their results are applied as soon as they arrive, even while waiting. And for that same reason, wait does not pair with them: in bg-transform-query(...)+wait, the background command completes only after wait has already been evaluated, so the search its result eventually triggers is not waited for. Use the synchronous transform-query(...) variant instead when chaining with wait. iykyk.

If the search takes long enough, fzf indicates that it's waiting by dimming the input, hiding the cursor, and showing (..) on the info line. This visual feedback is debounced so quick searches don't cause flickering. Very considerate of it honestly. ๐Ÿ’–

Note, bestie: when searches are triggered in rapid succession (e.g. via --listen), wait may unblock on the completion of an earlier search. Also, if the input source never completes, wait will block until cancelled. Forever. Just sitting there. ๐Ÿ˜ญ

๐Ÿ‘€ PREVIEW BINDING ๐Ÿ‘€

With the preview(...) action you can specify multiple different preview commands on top of the default preview command given by the --preview option. Mix and match, babe.

e.g.

# Default preview command with an extra preview binding
fzf --preview 'file {}' --bind '?:preview:cat {}'

# A preview binding with no default preview command
# (Preview window is initially empty)
fzf --bind '?:preview:cat {}'

# Preview window hidden by default, it appears when you first hit '?'
fzf --bind '?:preview:cat {}' --preview-window hidden

๐ŸชŸ CHANGE PREVIEW WINDOW ATTRIBUTES ๐ŸชŸ

The change-preview-window action lets you change the properties of the preview window. Unlike the --preview-window option, you can specify multiple sets of options separated by | characters. Rotating windows? We love a transformation moment. ๐Ÿฆ‹

e.g.

# Rotate through the options using CTRL-/
fzf --preview 'cat {}' --bind 'ctrl-/:change-preview-window(right,70%|down,40%,border-horizontal|hidden|right)'

# The default properties given by `--preview-window` are inherited, so an empty string in the list is interpreted as the default
fzf --preview 'cat {}' --preview-window 'right,40%,border-left' --bind 'ctrl-/:change-preview-window(70%|down,border-top|hidden|)'

# This is equivalent to toggle-preview action
fzf --preview 'cat {}' --bind 'ctrl-/:change-preview-window(hidden|)'

๐ŸŒธ AUTHOR ๐ŸŒธ

Junegunn Choi (junegunn.c@gmail.com) โ€” the literal main character, we stan. ๐Ÿ‘‘

๐Ÿ”— SEE ALSO ๐Ÿ”—

๐Ÿ“œ LICENSE ๐Ÿ“œ

MIT


And that's a wrap on the whole page, bestie!! ๐ŸŽ‰๐Ÿ’–โœจ This was fzf version 0.74.5, dated Oct 2026 โ€” go forth and fuzzy-find your little heart out. Periodt. ๐Ÿ’…๐ŸŒˆ๐Ÿฆ‹

๐Ÿ“ฆ where this page comes from