junegunn / fzf

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

Toggle between search modes #2643

Open akharrou opened 3 years ago

akharrou commented 3 years ago

Info

Feature request

Wouldn't the greatest search command of all time be able to dynamically choose/toggle through search modes, via bindings ?

rayiik commented 2 years ago

if this was a search command, sure but fzf is a filter that derives its input from search commands. Even fzf run just as $fzf still derives its input from FZF_DEFAULT_COMMAND and does not handle searching. However, This can be achieved with the

--bind:F1:"reload(command that searches using posix regex {+f})"
--bind:F2:"reload(command that uses posix extneded{+f})"
--bind:F3:"reload(pearl compatible regex {+f})"
--bind:F4:"reload(glob expression {+f})"
--bind:F5:"reload(literal expression {+f})"

you could have them all on one such as

declare -a list
list=( "poxix regular command" "posix extended command" "pearl regex" "glob expression" "literal expression" )
--bind:F1:"reload(select choice in "${list[@]}"; 
do
case $choice in
            posix regular command)
                                     command using posix regular against {+f}
                             ;;
            posix extended command)
                                     command using posix extended against {+f}
                            ;;
            perl regex)
                                    command using perl regex against {+f}
                           ;;
            glob expression)
                                   command using glob expression agasint {+f}
                        ;;
            literal expression)
                                  command using literal expression against {+f}
                          ;;
esac
done