junegunn / fzf

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

FZF output on multiple lines for data passed by pipeline through find command #3036

Closed lamyergeier closed 3 months ago

lamyergeier commented 2 years ago

Info

Problem / Steps to reproduce

Hey I checked the issues but I am not sure if this is answered, as it was mentioned that fzf doesn't support multiline command history.

But I wanted to ask if its possible to print long items in 2 lines instead of the ellipsis (2 dots) at the end, please see the following image:

image

I am doing something like this: File="$(find | fzf)"

If its not possible to print in multi line, is it possible to go to the end of each line to see the filename? This occurs when file path is too big to fit on one line!

LangLangBart commented 2 years ago

is it possible to go to the end of each line to see the filename?

fzf --keep-right

Alternative show the name in the preview

fzf --preview "echo {}" --preview-window 'nohidden:wrap'
SCR-20221115-16a
# just the filename
fzf --preview "basename {}" --preview-window 'nohidden:wrap'
SCR-20221115-17j

see the man page for more infos about --preview-window


Related threads:

lamyergeier commented 2 years ago

Thanks @LangLangBart I am using the basename solution that you described above (as in the below screenshot):

image

I was wondering if it was possible to high light the search letters in the preview box as well (with the blue colors) as shown in the above image.

LangLangBart commented 2 years ago

Maybe you can test if this works for you.

fzf --preview "basename {} | grep {q} -i --color=always" --preview-window 'nohidden:wrap'
# {q}  is  replaced to the current query string
# -i : ignore case
# --color=always 

EDIT

It would be better to use BurntSushi/ripgrep or ack, both of which have an additional --passthru flag to print matching and non--matching lines.

# ripgrep
fzf --preview "basename {} | rg --passthru -i {q} --color always" --preview-window 'nohidden:wrap'

# ack 
fzf --preview "basename {} | ack --passthru -i {q} --color" --preview-window 'nohidden:wrap'
junegunn commented 3 months ago

The latest version of fzf can print multi-line entries:

https://junegunn.github.io/fzf/tips/processing-multi-line-items/

And it can wrap long items:

https://junegunn.github.io/fzf/releases/0.54.0/