0

The following command works fine as expected:

find ~ -type f | fzf -m --preview-window=up:30% --header "ctrl-f: selected all and exit" --bind "enter:execute(less {})" --bind "ctrl-f:select-all+accept"

But if I add >outfile.txt or | xclip to the end of this command, all --bind options that contain execute action are ignored. Is this a known fault? Is there a way around it?

1
  • You need find -print0 and fzf --read0 to handle arbitrary file paths, and make sure $SHELL refers to a Bourne-like shell when using fzf's execute(). Oct 10, 2023 at 5:16

1 Answer 1

1

all --bind options that contain execute action are ignored

I don't think so. In my tests less does start. It does not behave as you expect because it inherits the redirected stdout from fzf. less reads keystrokes from the terminal even if its stdin is something else (so redirected input is not a problem); but it prints to its stdout (so redirected output is a problem, the problem). If you want to see what less prints and still redirect output from fzf, tell less specifically to use /dev/tty as its stdout:

find ~ -type f \
| fzf -m --preview-window=up:30% --header "ctrl-f: selected all and exit" \
--bind "enter:execute(less {} >/dev/tty)" \
--bind "ctrl-f:select-all+accept" >outfile.txt
1
  • Thanks Kamil. This is very interesting and exactly what I want. Odd that I have not seen this important point in any of the fzf documentations. Oct 10, 2023 at 7:09

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .