-
I'm trying to use fzf for tagging files. I have a shell script which opens files in a loop, presenting you with a fzf window for selecting tags for each one. I'm using multi-select mode, because obviously a file can have multiple tags. The complicated part is that I want to be able to tag with both pre-existing tags that were piped into fzf, as well as tags that don't yet exist, and therefore aren't in the input. In other words, I'm essentially using fzf as a fancy auto-complete, to make adding existing long tags less annoying to type. I found #3232 which mentions the trick of using
Does anyone know of a way to support this use-case of multi-selecting from both an existing set, and additional new options supplied by the user? |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 3 replies
-
This should give you some ideas. cat /usr/share/dict/words | fzf --header 'Press space to add the typed word' --multi \
--bind 'start:execute-silent(: > /tmp/added)' \
--bind 'space:execute-silent(echo {q} >> /tmp/added)+clear-query+refresh-preview' \
--preview '
echo "Selected words:"
echo {+} | sed "s/^/ - /"
echo
echo "Added words:"
cat /tmp/added | sed "s/^/ - /"
' |
Beta Was this translation helpful? Give feedback.
-
@junegunn From your following code snippet, in certain cases when none of the words from the file is suitable, is it possible to not choose any output from
May be we could bind '#' to just choose the newly added words. Is it possible? Or is there any better solution? |
Beta Was this translation helpful? Give feedback.
This should give you some ideas.