junegunn / fzf

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

How to restore old execute behavior? (so it doesn't output to /dev/tty) #3910

Closed tkossak closed 1 week ago

tkossak commented 1 week ago

Checklist

Output of fzf --version

0.53.0 (c4a9ccd6)

OS

Shell

Problem / Steps to reproduce

Latest update broke my workflow, because execute/echo now outputs to /dev/tty. How do I restore old behavior? I need it to capture fzf output to variables, not to write it to terminal. I use fzf with navi variables, but to simplify the example, run this in bash:

$ size=$(ls -l | fzf --bind 'enter:execute(echo {5})+abort')
4096
$ echo $size

$ 

How do I make $size variable contain 4096 (which I selected manually using fzf)? Thank you for any tips.

junegunn commented 1 week ago

See https://github.com/junegunn/fzf/issues/3865

tkossak commented 1 week ago

Thank you. It works with become:

$ echo "Size:" $(ls -l | fzf --bind 'enter:become:echo {5}')
Size: 4096

But it doesn't work with print:

$ echo "Size:" $(ls -l | fzf --bind 'enter:print({5})+abort')
Size:

Any idea why?

-- edit -- probably need to use accept instead of abort. And curly braces are not resolved with print, so I think I need to stick with become.

$ echo "Size:" $(ls -l | fzf --bind 'enter:print({5})+accept')
Size: {5} drwxr-xr-x 3 kossak kossak 4096 2023-01-26 airflow