fzf icon indicating copy to clipboard operation
fzf copied to clipboard

unable to restart fzf when file changes using entr

Open lgersman opened this issue 2 years ago • 0 comments

  • [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
    • [x] Linux
    • [ ] Mac OS X
    • [ ] Windows
    • [ ] Etc.
  • Shell
    • [x] bash
    • [ ] zsh
    • [ ] fish

Problem / Steps to reproduce

I often want to restart fzf (or a script executing fzf) when script files change for quicker development turnaround cycles. In other cases (using make and friends) i use entr as the "watch" tool.

I do not want to reload fzf data but the whole fzf (or even a script executing fzf)

But I am unable to restart fzf using entr for some reason.

Not working example:

find . -type f | entr -a -n sh -c 'find . -type f | fzf'

I tried a lot of quirky variants for watch/reload but they all seems to me too complicated.

(quirky) working example:

touch /tmp/fzf_pid
while [[ -f /tmp/fzf_pid ]]
do 
  find . -type f | entr -dd -c -p -n -z curl localhost:6266 -d 'execute:kill $(cat /tmp/fzf_pid)' & 
  fzf --listen 6266 --bind 'start:execute-silent(echo $PPID > /tmp/fzf_pid)' --bind 'esc:cancel+execute(rm /tmp/fzf_pid)'

  [[ "$?" -eq 0 ]] && exit
done

I am sure there is a much more easier option to watch files and reload fzf on changes.

Any help is welcome :-)

lgersman avatar Nov 17 '23 16:11 lgersman