How to return currently-typed text as the (only) result? #4536
-
|
I would like to make an fzf prompt for opening or creating a file. I have a prompt (below) that will search over the files that already exist, but it doesn't let me create new files because it doesn't allow the user to select the currently-typed text. Here is my prompt: Here's an example to test the prompt If I want to pick If I want to pick I know about the A workaround is to run a second picker on the results returned by Is there a way to do this with fzf? Or, is there maybe a different fuzzy finder that can do this? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 5 replies
-
Try MANWIDTH=120 fzf --man | col -b | grep -C2 accept-or-print-query
# accept enter double-click
# accept-non-empty (same as accept except that it prevents fzf from exiting without selection)
# accept-or-print-query (same as accept except that it prints the query when there's no match)
# backward-char ctrl-b left
# backward-delete-char ctrl-h ctrl-bspace bspaceseq 5 | fzf --query 'FOOBAR' --bind 'result:accept'
seq 5 | fzf --query 'FOOBAR' --bind 'result:accept-or-print-query'
# FOOBARAlternative: # If the env variable FZF_MATCH_COUNT (provided by fzf)
# is greater than zero, accept; otherwise, print the query.
seq 5 | fzf \
--bind 'result:transform:((FZF_MATCH_COUNT)) && echo accept || echo print-query' \
--query 'FOOBAR' \
--with-shell 'bash -c'
# FOOBARPS: the seq 5 | fzf \
--bind 'result:transform:((FZF_MATCH_COUNT)) && echo accept || echo "become: echo \{q}"' \
--query 'FOOBAR' \
--with-shell 'bash -c'
# FOOBARFootnotes |
Beta Was this translation helpful? Give feedback.

Try
accept-or-print-queryactionAlternative:
t…