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. ๐
๐ SEARCH ๐
-x,--extendedโ Extended-search mode. this is enabled by default, bestie, she comes pre-slaying. you can turn it off with+xor--no-extendedif 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 overdefaultif 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) withfzfwhile 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,fzfbecomes a simple selector interface rather than a "fuzzy finder". You can later enable the search usingenable-searchortoggle-searchaction. 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 lengthchunkโ Prefers line with shorter matched chunk (delimited by whitespaces)pathnameโ Prefers line with matched substring in the file name of the pathbeginโ Prefers line with matched substring closer to the beginningendโ Prefers line with matched substring closer to the endindexโ Prefers line that appeared earlier in the input stream
the rules of the game: ๐ฏ
- Each criterion should appear only once in the list
indexis only allowed at the end of the listindexis implicitly appended to the list when not specified- Default is
length(or equivalentlylength,index) - If
endis found in the list,fzfwill 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,fzfwill launch the finder only after the input stream is complete and the initial filtering and the associated actions (bound to any ofstart,load,result,result-final, orfocus) 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โ Makefzfsearch for the current TTY device via standard error instead of defaulting to/dev/tty. This option avoids issues when launchingemacsclientfrom withinfzf. 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:darkon 256-color terminal, otherwisebase16; IfNO_COLORis set,bw)
darkโ Color scheme for dark terminallightโ Color scheme for light terminalbase16โ 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 textlist-fgโ text in the list sectionselected-fgโ selected line text
preview-fgโ preview window text
bgโ the backgroundlist-bgโ list section backgroundselected-bgโ selected line background
preview-bgโ preview window backgroundinput-bgโ input window backgroundheader-bgโ header window backgroundfooter-bgโ footer window background
hlโ highlighted substringsselected-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 linesalt-gutterโ alternate gutter color to create the striped patternquery(input-fg) โ query stringghostโ 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 (--borderand--preview)list-borderโ border around the list section (--list-border)scrollbarโ scrollbarseparatorโ horizontal separator on info linegap-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โ promptpointerโ pointer to the current linemarkerโ multi-select markerspinnerโ streaming input indicatorheader(header-fg) โ headerfooter(footer-fg) โ footernthโ 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:blackredgreenyellowbluemagentacyanwhitebright-black(gray|grey)bright-redbright-greenbright-yellowbright-bluebright-magentabright-cyanbright-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 onesstripโ remove colorsboldunderlineunderline-doubleunderline-curlyunderline-dottedunderline-dashedreversedimitalicstrikethrough
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--heightis 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--heightis 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 (defaultcenter,50%). Requires tmux 3.3+ or Zellij 0.44+. This option is ignored if you are not running fzf inside tmux or Zellij.--tmuxis 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 screenreverseโ display from the top of the screenreverse-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 leftTB,RLโ vertical, horizontal marginT,RL,Bโ top, horizontal, bottom marginT,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--borderoption 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 leftTB,RLโ vertical, horizontal paddingT,RL,Bโ top, horizontal, bottom paddingT,R,B,Lโ top, right, bottom, left padding
--border[=STYLE]โ draw border around the finderroundedโ border with those cute rounded corners (this one's the default, bestie) ๐sharpโ border with sharp cornersboldโ border with bold linesdoubleโ border with double linesdashedโ border with dashed lines and rounded cornersblockโ border made of block elements; lowkey the move when you're using different background colorsthinblockโ border using legacy computing symbols; fair warning, this may not show up on some terminals ๐ญhorizontalโ horizontal lines sitting above and below the finderverticalโ vertical lines down each side of the finderlineโ a single line border (position is automatically determined)top(akaup) ๐bottom(akadown) ๐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:
roundedsharpbolddoublehorizontaltop(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
Thelabelvariable in that example is the SHELL VARIABLE, not thelabelelement of--color. But also, the--color=label:italic:blackDOES 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.MODEcan bechar(the default) orword. Thewordmode wraps lines at word boundaries (spaces and tabs) instead of at arbitrary character positions. Oh and--wrap-wordis 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--tacbecause 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 acrossreloadandreload-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=1instead 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-unicodeis given)--gutter-raw=CHARโ the character used for the gutter column in raw mode (default:'โ'unless--no-unicodeis 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 optionalCHAR2is 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, thelinestyle 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 thesearchaction. You can later show the input section again using theshow-inputortoggle-inputaction, and hide it again withhide-input, ortoggle-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 separatorrightโ on the right end of the horizontal separatorhiddenโ do not display finder infoinlineโ after the prompt with the default prefix' < 'inline:PREFIXโ after the prompt with a non-default prefixinline-rightโ on the right end of the prompt lineinline-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_INFOvariable 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-wordbackward-wordforward-wordkill-word
--input-border[=STYLE]โ bestie, this draws a border all up around the input section. And if you picklineas 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. Andlinestyle 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-windowoptions:border-rounded(default on non-Windows platforms)border-sharp(default on Windows)border-boldborder-doubleborder-dashedborder-blockborder-thinblockborder-horizontalborder-topborder-bottom
--preview-wrap-sign=INDICATORโ the indicator for wrapped lines in the preview window. If it's not set, the value of--wrap-signis 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:bottomto put it on the border line at the bottom instead. The default value0(orcenter) 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)
updownleftrightnext
This decides the layout of the preview window. Let's get into it:
nextplaces 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 thetoggle-previewaction 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
wrapflag. Thewrap-wordflag 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
followflag is set, similarly to howtail -fworks.
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
cycleflag. - 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
--borderwith theborder-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-linestyle 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.SCROLLcan 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
OFFSETSpart is for adjusting the base offset. It should be given as a series of signed integers (-INTEGERor+INTEGER). - The final
/DENOMpart is for specifying a fraction of the preview window height.
~HEADER_LINESkeeps the top N lines as the fixed header so that they're always visible. ๐defaultresets 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)'
โจ HEADER โจ
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--layoutis doing, and--with-nthcan't touch them. ANSI color codes get processed even when--ansiis not set. iconic โจ--header-lines=Nโ the firstNlines of the input become the sticky header. if--with-nthis 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.linestyle draws a single separator line between the header window and the list section.inlinestyle embeds the header inside the list border frame, joined to the list section by a horizontal separator โ it requires a--list-bordershape that has both top and bottom segments (rounded/sharp/bold/double/dashed/block/thinblock/horizontal) and falls back tolineotherwise. when the list border also has side segments, the separator joins them with T-junctions;horizontalhas 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-linesis also set,--header-lines-bordermust also beinline. 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-lineswith a separate border. passnoneto still separate the header lines but without a border. to combine two headers, use--no-header-lines-border.linestyle draws a single separator line between the header lines and the list section.inlinestyle embeds the header lines inside the list border frame with a horizontal separator; it requires a--list-bordershape that has both top and bottom segments, and falls back tolineotherwise. ๐ธ
๐ฆ FOOTER ๐ฆ
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-nthdoes not affect them. ANSI color codes are processed even when--ansiis not set. ๐--footer-border[=STYLE]โ draw a border around the footer section.linestyle draws a single separator line between the footer and the list section.inlinestyle embeds the footer inside the list border frame with a horizontal separator; it requires a--list-bordershape that has both top and bottom segments and falls back tolineotherwise. โจ--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-queryis also used). the line will be empty if fzf is completed with the default enter key. if--expectis specified multiple times, fzf expects the union of all those keys.--no-expectclears 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 runtput rmcupto 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 thereloadaction 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 -cif$SHELLis set, otherwisesh -c. on Windows, the default value iscmd /s/cwhen$SHELLis 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.sockextension.- if the port number is omitted or given as
0, fzf will automatically choose a port and export it as theFZF_PORTenvironment 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_SOCKenvironment variable. - if the
FZF_API_KEYenvironment variable is set, the server would require sending an API key with the same value in thex-api-keyHTTP header. ๐ FZF_API_KEYis required for a non-localhost listen address.- to allow remote process execution, use
--listen-unsafe. โ ๏ธ (yes, the name is the warning, bestie)
- if the port number is omitted or given as
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 ismin(8 * NUM_CPU, 32). parallel queen ๐ธ--bench=DURATIONโ repeatedly run--filterfor 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_COMMANDis not set. the default value isfile,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. skippingnode_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 tonext-historyandprev-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 -cifSHELLis set, otherwise withsh -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=~/.fzfrcFZF_API_KEYโ you can use this to require an API key when using the--listenoption. 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 thebecomeaction.127โ Invalid shell command for thebecomeaction.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 field2โ the 2nd field-1โ the last field-2โ the 2nd to last field3..5โ from the 3rd field to the 5th field2..โ 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 marginFZF_COLUMNSโ number of columns fzf takes up, excluding padding and marginFZF_DIRECTIONโ direction of the list (upordown)FZF_TOTAL_COUNTโ total number of itemsFZF_MATCH_COUNTโ number of matched itemsFZF_SELECT_COUNTโ number of selected itemsFZF_POSโ vertical position of the cursor in the list, starting from 1FZF_CURRENT_ITEMโ text of the current item (unset if the list is empty)FZF_WRAPโ the line wrapping mode (char,word) when enabledFZF_QUERYโ current query stringFZF_INPUT_STATEโ current input state (enabled,disabled,hidden)FZF_NTHโ current--nthoptionFZF_WITH_NTHโ current--with-nthoptionFZF_PROMPTโ prompt stringFZF_GHOSTโ ghost stringFZF_POINTERโ pointer stringFZF_PREVIEW_LABELโ preview label stringFZF_BORDER_LABELโ border label stringFZF_LIST_LABELโ list label stringFZF_INPUT_LABELโ input label stringFZF_HEADER_LABELโ header label stringFZF_ACTIONโ the name of the last action performedFZF_KEYโ the name of the last key pressedFZF_IDLE_TIMEโ whole seconds since the last user activityFZF_IDLE_TIME_MSโ milliseconds since the last user activityFZF_PORTโ port number when the--listenoption is usedFZF_SOCKโ Unix socket path when the--listenoption is usedFZF_PREVIEW_TOPโ top position of the preview windowFZF_PREVIEW_LEFTโ left position of the preview windowFZF_PREVIEW_LINESโ number of lines in the preview windowFZF_PREVIEW_COLUMNSโ number of columns in the preview windowFZF_RAWโ only in raw mode.1if the current item matches,0otherwise
okay heads up bestie,FZF_CURRENT_ITEMgets omitted when the item contains a NUL byte, becauseexec(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.
xxx foo xxx(highest score)xxx foo_xxxxxx_foo xxxxxx_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 asresult, 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> "
)'
click-footer
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,escacceptโ say yes and get out ๐ Default:enter,double-clickaccept-non-emptyโ same asacceptexcept that it preventsfzffrom exiting without a selection.accept-or-print-queryโ same asacceptexcept that it prints the query when there's no match.backward-charโ Default:ctrl-b,leftbackward-delete-charโ Default:ctrl-h,ctrl-bspace,bspacebackward-delete-char/eofโ same asbackward-delete-charexcept it abortsfzfif the query is empty.backward-kill-subwordโ no default binding, she's freelance ๐backward-kill-wordโ Default:alt-bsbackward-subwordโ no default binding.backward-wordโ Default:alt-b,shift-left,alt-leftbecome(...)โ replace thefzfprocess with the specified command; see below for the details.beginning-of-lineโ Default:ctrl-a,homebellโ ring the terminal bell ๐bestโ move to the best match; same asfirstif raw mode is disabled.bg-cancelโ cancel background transform processes.cancelโ clear the query string if it's not empty, abortfzfotherwise.change-border-label(...)โ change--border-labelto 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-labelto the given string.change-input-label(...)โ change--input-labelto the given string.change-list-label(...)โ change--list-labelto the given string.change-multiโ enable multi-select mode with no limit.change-multi(...)โ enable multi-select mode with a limit, or disable it with0.change-nth(...)โ change the--nthoption; rotate through the multiple options separated by'|'.change-with-nth(...)โ change the--with-nthoption; rotate through the multiple options separated by'|'.change-pointer(...)โ change the--pointeroption.change-preview(...)โ change the--previewoption.change-preview-label(...)โ change--preview-labelto the given string.change-preview-window(...)โ change the--preview-windowoption; 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-lclear-multiโ clear the multi-selection.closeโ close the preview window if it's open, abortfzfotherwise.clear-queryโ clear the query string.delete-charโ Default:deldelete-char/eofโ Default:ctrl-dโ same asdelete-charexcept it abortsfzfif 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, useclear-multi.disable-rawโ disable raw mode.disable-searchโ disable the search functionality.downโ Default:ctrl-j,downdown-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,endexcludeโ 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 aspos(1).forward-charโ Default:ctrl-f,rightforward-subwordโ no default binding.forward-wordโ Default:alt-f,shift-right,alt-rightignoreโ 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-dlastโ move to the last match; same aspos(-1).next-historyโctrl-non--history.next-selectedโ synonym todown-selected.page-downโ Default:pgdnpage-upโ Default:pguphalf-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-pon--history.prev-selectedโ synonym toup-selected.preview(...)โ see below for the details.preview-downโ Default:shift-downpreview-upโ Default:shift-uppreview-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 afterunbind.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 anfzfsearch with the given string.selectโ yes bestie, the other half ofdeselect๐ 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-clicktoggle-allโ toggle all matches.toggle-inโ--layout=reverse*?toggle+up:toggle+downtoggle-outโ--layout=reverse*?toggle+down:toggle+uptoggle-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-linesusing 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 anfzfsearch 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-uunix-word-ruboutโ Default:ctrl-wuntrack-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,upup-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 exitsfzfโ likeacceptorabortโ 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),waitmay unblock on the completion of an earlier search. Also, if the input source never completes,waitwill 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 ๐
- Project homepage:
https://github.com/junegunn/fzf - Extra Vim plugin:
https://github.com/junegunn/fzf.vim
๐ 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
- arch rolling: fzf 0.74.5-1 ยท MIT
- fedora 43: fzf 0.74.5-1.fc43 ยท MIT
- fedora 44: fzf 0.74.5-1.fc44 ยท MIT
- nixpkgs unstable: fzf 0.74.5
- nixpkgs unstable: vimplugin-fzf 0.74.5
- ๐ girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms