Skip to content

Positional params passed to preview_cmd  #81

@textgoeshere

Description

@textgoeshere

The README states that each line from list_cmd should provide at least three fields plus an optional fourth. preview_cmd then can access the first field as {1} and the fourth, optional, as {2}:

The list_cmd generated the list of entries. For each entry, it has to print the following columns, separated by the \034 field separator character:

The item to launch. This will get passed to preview_cmd and launch_cmd as {1}
The name of your provider (the same as what what you put inside the brackets, so my-provider in this example)
The text that appears in the fzf window. You might want to prepend it with a glyph and add some color via ANSI escape codes
(optional) Metadata that you can pass to preview_cmd and launch_cmd as {2}. For example, this is used to specify a specific Desktop Action inside a .desktop file
The preview_cmd renders the contents of the fzf preview panel. You can use the template variable {1} in your command, which will be substituted with the value of the selected item.

However, with a minimal test provider like this:

[test]
list_cmd=echo -e "item-to-launch1\034test\034fzf-text1\034optional-metadata1\nitem-to-launch2\034test\034fzf-text2\034optional-metadata2\n"
preview_cmd=echo "${@}"
launch_cmd=echo "na"
purge_cmd=echo "na"

The name of the provider (here, "test") is passed to preview_cmd as {1} and the item to launch is passed as {2}. Contrary to the docs, the optional metadata is not available to preview_cmd.

A simple, backwards-compatible, way of addressing this would be to pass the whole line from list_cmd through to preview_cmd from fzf ie. on l317

  --preview "$0 describe {2} {1} {+}"

(Plus updating the docs.)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions