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

Created on 10 May 2020  路  2Comments  路  Source: junegunn/fzf

  • [x] I have read through the manual page (man fzf)
  • [x] I have the latest version of fzf
  • [x] I have searched through the existing issues

Info

  • OS

    • [ ] Linux

    • [x] Mac OS X

    • [ ] Windows

    • [ ] Etc.

  • Shell

    • [ ] bash

    • [x] 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.

Most helpful comment

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

All 2 comments

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.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

aleclarson picture aleclarson  路  3Comments

skamsie picture skamsie  路  3Comments

erusev picture erusev  路  3Comments

nordlow picture nordlow  路  3Comments

olethanh picture olethanh  路  3Comments