-
Hello. I am trying to achieve the situation where my query is printed and fzf exits with non-0 status code. Is there a way to do it? Reproducing example:
I have also tried The usecase where I would like to use this situation is optionally command accepting in history widget. Something like: fzf-patch-history-widget() {
fzf-history-widget
# if the exit code 0 -- zle accept-line
# else -- do nothing, let me edit the command
} I have seen issue #2075 and tried
That is the problem I am stuck in, the exit code is 0 even if I press escape. Version: |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 2 replies
-
Well, I think I have come with an idea for my "usecase". Instead of exit-code I can use a temporary file. So, if the command should be processed with So, my resulting zshrc is:
Thus, I am able to use
However, it will be still wonderful, if there will be a way to print-query and exit with non-0 exit code :) |
Beta Was this translation helpful? Give feedback.
-
See #477 for an auto-accept workaround in zsh
Try this source <(fzf --zsh)
FZF_CTRL_R_OPTS='--bind "esc:transform:[[ -n $FZF_QUERY ]] && echo print-query || echo abort"' See #3612 for an explanation on the syntax and the man page: man fzf | less --pattern='TRANSFORM ACTIONS' --ignore-case |
Beta Was this translation helpful? Give feedback.
-
The classic approach using
|
Beta Was this translation helpful? Give feedback.
The classic approach using
--expect
and--print-query
And you press esc, alt-enter, or enter as usual.
esc
,alt-enter
, or an empty string (enter)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 workprint(...)
action queues the string to the output buffer, and it is printed only onaccept
, so onabort
, you don't se…