jethrokuan / fzf

Ef-🐟-ient fish keybindings for fzf
MIT License
863 stars 65 forks source link

Document FZF_PREVIEW_FILE_CMD and FZF_PREVIEW_FILE_CMD #125

Open thernstig opened 4 years ago

thernstig commented 4 years ago

I could not find any documentation in regards to FZF_PREVIEW_FILE_CMD and FZF_PREVIEW_DIR_CMD.

My initial thought it would be the commands used automatically if I do fzf --preview. But seeing as this repo's main headline is "Ef-🐟-ient fish keybindings for fzf" I am guessing the two env vars do something else.

Please enlighten us :)

jethrokuan commented 4 years ago

The two variables you listed above are the same, so I'm going to answer wrt to just FZF_PREVIEW_FILE_CMD.

This repo provides a widget to preview the file that you're completing for, see https://github.com/jethrokuan/fzf/wiki/FZF-Tab-Completions.

the FZF_PREVIEW_FILE_CMD variable contains the variable to preview the given file. E.g. if it's head -n 10 then the first 10 lines of the file is shown in the preview pane.

thernstig commented 4 years ago

@jethrokuan I updated the original question as I got one of the vars wrong.

The page you link to is about if you have tab completions enabled. Are you saying that the command that FZF_PREVIEW_FILE_CMD points to is only used in relation to when FZF_COMPLETE is used? Or is it that FZF_PREVIEW_FILE_CMD is used anytime you use --preview with fzf?

FZF_COMPLETE is not documented on the first page (the readme), but FZF_COMPLETE_OPTS is.

I would also add that FZF_ENABLE_OPEN_PREVIEW is something I did not understand from the comment for that command. Does the comment mean that --preview gets auto-added to all invocations of fzf?

jethrokuan commented 4 years ago

The page you link to is about if you tab completions enabled. Are you saying that the command that FZF_PREVIEW_FILE_CMD points to is only used in relation to when FZF_COMPLETE is used? Or is it FZF_PREVIEW_FILE_CMD is anytime you use --preview with fzf?

Yes, only when FZF_COMPLETE is used.

FZF_COMPLETE is not document on the first page (the readme), but FZF_COMPLETE_OPTS is, just a note.

A link to the wiki page is on the readme, but perhaps I should've made it more obvious. I'd consider it secondary to everything else on the readme.

I would also add that FZF_ENABLE_OPEN_PREVIEW is something I did not understand from the comment for that command. Does the comment mean that --preview gets autoadded to all invocations of fzf?

--preview gets added, only for the open command (__fzf_open).

thernstig commented 4 years ago

This would be a breaking change, but my recommendation to make this more understandable for a user would be to:

  1. Add FZF_COMPLETE to the Variables table (for easy overview of all commands).
  2. Rename FZF_PREVIEW_FILE_CMD to FZF_COMPLETE_PREVIEW_FILE_CMD (breaking change)
  3. Rename FZF_PREVIEW_DIR_CMD to FZF_COMPLETE_PREVIEW_DIR_CMD (breaking change)
  4. Possibly make it so that FZF_ENABLE_OPEN_PREVIEW also adds --preview to "find a file" and "cd into" commands.

Of course, you can reject, none, or some of the ideas. But if you like any of them, I could write separate issues to close this thread. Or keep it open if you prefer of course :)

c02y commented 3 years ago

Hi, it seems FZF_PREVIEW_FILE_CMD and FZF_PREVIEW_DIR_CMD are only working for fzf-tab, not for the bindings in repo's home page, but I got --preview for fzf in FZF_DEFAULT_OPTS which will work for C-o, but it is not working for dir preview in the bindings, and it is trying to work for C-r but failed for history which preview should be avoid for C-r.

PR https://github.com/jethrokuan/fzf/pull/175 PR2 https://github.com/jethrokuan/fzf/pull/173