๐Ÿ“‚ sfzf

โšก sfzf::show

Displays a menu where the user can search and select an item. The menu is displayed in full screen. Each item can optionally have a description/details shown in a right panel. The user can search for an item by typing.

Inputs:

  • $1: array name as string:

    The items to display (name of a global array).

  • ${prompt} as string:

    (optional) The prompt to display to the user (e.g. Please pick an item).

    (defaults to “Select an item:”)

  • ${itemDetailsCallback} as string:

    (optional) The function to call when an item is selected this parameter can be left empty to hide the preview right pane; otherwise the callback function should have the following signature:

    • $1: the current item
    • $2: the item number;
    • $3: the current panel width;
    • it should return the details of the item in the REPLY variable.

    (defaults to empty, no callback)

  • $(previewTitle) as string:

    (optional) the title of the preview right pane (if any)

    (defaults to “Details”)

Returns:

  • ${REPLY}: The selected item value (or empty).
  • ${REPLY2}: The selected item index (from the original array). Or -1 if the user cancelled the selection

Example usage:

declare -g -a SELECTION_ARRAY
SELECTION_ARRAY=("blue" "red" "green" "yellow")
sfzf::show "What's your favorite color?" SELECTION_ARRAY
log::info "You selected: โŒœ${REPLY}โŒ (index: โŒœ${REPLY2}โŒ)"

Important

Documentation generated for the version 0.33.0 (2025-08-31).