junegunn / fzf

:cherry_blossom: A command-line fuzzy finder
https://junegunn.github.io/fzf/
MIT License
65.81k stars 2.41k forks source link

arbitrary shell commands with transform function of fzf #4064

Closed sabarish-vm closed 1 month ago

sabarish-vm commented 1 month ago

Checklist

Output of fzf --version

0.55.0 (brew)

OS

Shell

Problem / Steps to reproduce

Hi, Thanks for all you put in to maintaining this amazing tool. I am trying to use transform, to create a keybinding as given in the ADVANCED.md file. That is,

--bind "ctrl-f:transform: $HOME/.dotfiles/fzf/fzf_level \$FZF_PROMPT"

The above command fzf_level contains the following, prompt="$1" if [[ ! "$prompt" =~ F ]]; then echo 'change-prompt(F> )+reload(fd --type file . )' else echo 'change-prompt(D> )+reload(fd --type directory . )' fi

Is something like this not possible ? The reason I want to do it in a separate script is to have more complicated branching and condition checking eventually.

junegunn commented 1 month ago

It should work, except you have to escape the second $ to avoid immediate evaluation (i.e. \$FZF_PROMPT) or use the single-quotes.