Using fzf I want to be able to see the lines before and after the matched result when making a search. By default only the matched line is displayed.
It looks like this feature hasn't been implemented in fzf just yet, (although the author makes no suggestion that it will be in future) but does provide a work around using fzf --preview
I don't know if that suits your particular use case but I was trying to find a certain git sha from the git history of repo where I knew a portion of the commit message. I couldn't get it to work with git log
directly so I sent the whole log to a file, git_log
, and used that instead:
fzf --preview 'tail +$(( {n} - 3 )) git_log' < git_log
(augmented version of the command provided in the Github issue)
{n} - 3
is 3 lines before the line that's matched, {n}
being the zero-based index of the matching line.
The preview window should show the previous 3 lines then the line that's matched and then the rest of the git_log
file until the end of the preview window.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With