Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Positional params passed to preview_cmd #81

Open
textgoeshere opened this issue Dec 14, 2023 · 0 comments
Open

Positional params passed to preview_cmd #81

textgoeshere opened this issue Dec 14, 2023 · 0 comments

Comments

@textgoeshere
Copy link

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.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant