Skip to content

Question about "print-query+abort" #4188

Closed Answered by junegunn
Toliak asked this question in Q&A
Discussion options

You must be logged in to vote

The classic approach using --expect and --print-query

fzf --expect esc,alt-enter --print-query

And you press esc, alt-enter, or enter as usual.

  • Then the first line of the output is the name of the key, esc, alt-enter, or an empty string (enter)
  • The second line of the output is the current query
  • The third line is the selected item

So you look at the first line and determine what to do with the output.

Using --become

fzf --bind 'esc:become:echo {q}; exit 1'

fzf becomes echo {q}; exit 1 process and it will do what you want in a simpler way.

Why print(xxx)+abort doesn't work

print(...) action queues the string to the output buffer, and it is printed only on accept, so on abort, you don't se…

Replies: 3 comments 2 replies

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
1 reply
@Toliak
Comment options

Comment options

You must be logged in to vote
1 reply
@Toliak
Comment options

Answer selected by Toliak
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants