junegunn/fzf

`fzf` using `--no-clear` and `execute`

bigH opened this issue · 2 comments

bigH commented
  • I have read through the manual page (man fzf)
  • I have the latest version of fzf
  • I have searched through the existing issues

Info

  • OS
    • Linux
    • Mac OS X
    • Windows
    • Etc.
  • Shell
    • bash
    • zsh (iTerm & Alacritty)
    • fish

Problem / Steps to reproduce

Run this command (tried execute-silent also):

fzf --no-clear --bind 'enter:execute(fzf)'

When pressing Enter, I expect the fzf -> fzf transition to be seamless, instead I see a blinking of my terminal.

It seems that --no-clear is great if you exit fzf and re-run it. In this case, building "stacking" fzf's is not possible.

Hi, I found this trick to invoke fzf from within --bind with no flickering:

  1. use execute-silent to prevent any screen switching
  2. redirect stderr to /dev/tty so that your "internal" fzf displays ok
  3. use clear-screen after your command to repaint the "initial" fzf finder

Everything then displays on alternate screen with no screen flashing.
Here's one example (press F1):
find . -type f | fzf --bind 'f1:execute-silent(cat {} | fzf 2>/dev/tty)+clear-screen'

Best Regards,
Florian

execute by design runs the command in the alternate screen which is not affected by --no-clear. I would recommend that you implement the "stacking" using shell script outside of fzf, rather than circumventing the limitations of execute bindings.

But the solution @notevenodd posted is quite clever.