junegunn / fzf

:cherry_blossom: A command-line fuzzy finder
https://junegunn.github.io/fzf/
MIT License
65.81k stars 2.41k forks source link

Allow specifying '{n}' as the OFFSET in the preview-window flag #4079

Closed jaydee-coder closed 3 weeks ago

jaydee-coder commented 3 weeks ago

This feature can be useful in scrolling to the selected line in the preview window.

For example, it can be used to use fzf as a quick filtering tool for large files while keeping an eye on the selected line as it shows up in the original file.

Example usage:

man fzf | tee /tmp/tmp.log | fzf \
  --reverse \
  --exact \
  --query 'position' \
  --preview 'bat --force-colorization /tmp/tmp.log --highlight-line $(({n}+1))' \
  --preview-window '+{n}/2'
junegunn commented 3 weeks ago

Merged, thanks!