package fzf

  1. Overview
  2. Docs
Legend:
Library
Module
Module type
Parameter
Class
Class type

Functions for calling out to fzf, the command-line fuzzy finder, from within terminal applications. See man fzf for more details.

Some higher-level interfaces for constructing UIs using fzf exist. See Fzf_selector.

module Streaming : sig ... end
module Pick_from : sig ... end

Pick_from instructs Fzf to choose from a given input and perhaps select an output that wasn't the string selected.

module Tiebreak : sig ... end

Tiebreak instructs Fzf how to sort lines when the "matching scores" are tied. See fzf(1) for more documentation.

type ('a, 'return) pick_fun = ?fzf_path:string -> ?select1:unit -> ?query:string -> ?header:string -> ?preview:string -> ?preview_window:string -> ?no_sort:unit -> ?reverse_input:unit -> ?prompt_at_top:unit -> ?with_nth:string -> ?nth:string -> ?delimiter:string -> ?height:int -> ?bind:string Nonempty_list.t -> ?tiebreak:Tiebreak.t Nonempty_list.t -> ?filter:string -> ?border:[ `rounded | `sharp | `horizontal ] -> ?info:[ `default | `inline | `hidden ] -> ?exact_match:unit -> ?no_hscroll:unit -> ?case_match:[ `case_insensitive | `case_sensitive | `smart_case ] -> 'a Pick_from.t -> 'return
val pick_one : ('a, 'a option Async.Deferred.Or_error.t) pick_fun

pick_one ?query ?header ?preview items will display a visual selector from items. If pick_one items evaluates to Some x, it is guaranteed that x is a member of items.

If items is empty, pick_one just returns None.

If query is provided, the finder will start the search as if query had been typed already.

If select1 is passed and either items has length 1 or query matches exactly 1 item, the lone item will be immediately returned without a prompt.

If preview is provided, it specifies the preview string provided to fzf. See the Preview section of man fzf (1). E.g. ~preview:"cat {

}

" will cat out the current selection and display it. Programs may want specify a preview string that causes itself to be exec'd in order to generate valuable previews.

If preview_window is provided, it specifies the dimensions and format of the preview window that fzf displays. See the Preview section of man fzf (1). E.g. ~preview_window:"top:99%:wrap" will display the preview window above fzf's prompt, cause it to take up 99% of the screen, and automatically wrap text in the window.

If no_sort is passed, fzf will not sort the filtered results displayed to the user. That is, they will appear in the same order as in items instead of in order of relevance.

If reverse_input is passed, fzf will display the initial list of options in reverse order to how it usually does (first line closest to the prompt). (This passes the --tac flag to fzf)

If prompt_at_top is passed, fzf will display the fuzzy finder's prompt at the top of the window, instead of at the bottom. (This passes the --reverse flag to fzf)

If with_nth is passed fzf will only show part of every item, e.g. "2.." means "for every item show everything from 2nd field onwards" (n.b. fields are 1 indexed).

If nth is passed fzf will only match part of every item, e.g. "2.." means "for every item only match from 2nd field onwards" (n.b. fields are 1 indexed).

If delimiter is passed fzf will use this to delimit items (as used in with_nth, nth and preview)

If height is passed, fzf window will be displayed below the cursor with the given height instead of using fullscreen. (This passes the --height flag to fzf)

If bind is passed, the default key bindings will be redefined according to the format of fzf --bind flag. While fzf allows you to pass multiple bindings in a single instance of the --bind flag by separating the bindings with commas, some commands cannot be followed by a comma (e.g. the 'preview' command can't be followed by a comma because there is no way to delineate the 'end' of a preview command, and so fzf treats the comma as part of the command). To work around this, every element of bind causes the --bind flag to be passed to fzf again - e.g. ("ctrl-l:preview:echo hi"; "ctrl-k:kill-line" causes this to pass --bind "ctrl-l:preview:echo hi" --bind "ctrl-k:kill-line".

If exact_match is passed, fzf will use exact-match rather than fuzzy-match for each word in the query. (This passes the --exact_match flag to fzf)

If no_hscroll is passed, fzf will disable horizontal scroll. (This passes the --no-hscroll flag to fzf.)

If case_match is provided, fzf will use case-insensitive or case-sensitive match. (This passes a case flag to fzf where `case_insensitive corresponds to -i, `case_sensitive corresponds to +i, and `smart_case passes no arg in order to default to smart-case match. See man fzf (1) for more information.)

val pick_many : ('a, 'a list option Async.Deferred.Or_error.t) pick_fun

pick_many will present the user with a multi-select prompt.

The user can select multiple results at once by using TAB to select and SHIFT + TAB to unselect. All current results can be selected using CTRL + A.

For documentation on the other options to this function see pick_one.

val pick_one_abort : abort:unit Async.Deferred.t -> ('a, ('a option, [ `Aborted ]) Core.Either.t Async.Deferred.Or_error.t) pick_fun

These functions allow the fzf select to be aborted by providing an abort : unit Deferred.t.

If abort becomes determined before a selection is made, the fzf screen closes and `Aborted is returned, otherwise result is returned, where result would be the value returned by pick_one/pick_many

val pick_many_abort : abort:unit Async.Deferred.t -> ('a, ('a list option, [ `Aborted ]) Core.Either.t Async.Deferred.Or_error.t) pick_fun
module Blocking : sig ... end
val complete_subcommands : show_help:bool -> path:string list -> part:string -> string list list -> string list option

complete_subcommands ~show_help is intended to be used as the argument to Command.runs complete_subcommands argument.

show_help determines if command help is shown alongside the subcommand during selection as a preview.

val complete : choices:(Core.Univ_map.t -> string list) -> Async.Command.Auto_complete.t

complete ~choices is intended to be used as the argument to Command.Arg_types complete argument.

complete_enumerable is a convenience wrapper for complete to use with ppx_enumerate using to_string.

val complete_enumerable_sexpable : (module Async.Command.Enumerable_sexpable) -> Async.Command.Auto_complete.t

complete_enumerable_sexpable is a convenience wrapper for complete to use with ppx_enumerate using sexp_of_t to turn the value into a string.

val key_with_hidden_part : string -> hidden:string -> string

Helper function for generating a key with a hidden part. Fzf will show only the visible part but will search in both visible and hidden parts.

The implementation just tacks hidden onto the visible part of the key after a large enough amount of whitespace that it is very unlikely fzf will display hidden. Kind of a kludge, but a useful one.

OCaml

Innovation. Community. Security.