Reload with pre-selected items
I am trying to create a binding that reloads the list and pre-selects items in the updated list. I looked at https://github.com/junegunn/fzf/issues/4396 and tried to do something like:
echo -e "1\n2\n3" | fzf --sync --multi --bind 'ctrl-a:reload-sync(echo -e 9\\n8)+pos(1)+select'
but the result is that the selection happens on the initial list, then the list gets updated with no selection.
I tried some other variations of my command but could not get it to work how I wanted.
echo -e "1\n2\n3" | fzf --multi --bind ctrl-a:reload:'echo -e 9\\n8;touch /tmp/reloaded' --bind result:transform:'[[ -f /tmp/reloaded ]] && rm /tmp/reloaded && echo "pos(1)+select"'
Thank you, @nenahp! That does indeed work. Is there a possible solution that doesn't depend on side effects like creating a temp file as a flag? I would like to chain many such actions together and this approach might not scale well.
I don't know. Maybe you can use --listen. Then you can bind to a complex script. The script use curl localhost:$FZF_PORT to GET the state of fzf, or request some actions with POST.
If your requirement is simple (e.g. selecting the first entry), you can bind actions to perform on load event.
fzf --multi --bind 'load:pos(1)+select' --bind 'space:reload(ls)+clear-query'
To avoid triggering the actions on load of the initial list,
fzf --multi --bind 'start:unbind(load),load:pos(1)+select' --bind 'space:rebind(load)+reload(ls)+clear-query'