Replies: 4 comments
-
How about this approach. #!/usr/bin/env bash
_some_command()
{
# when $PWD is empty
if [[ -z "$(ls -A)" ]]; then
return 100
fi
}
export -f _some_command
fzf \
--bind 'start:transform:
_some_command
_exit_status="$?"
if (( _exit_status > 0 )); then
echo "change-prompt($_exit_status )"
fi' |
Beta Was this translation helpful? Give feedback.
-
Note fzf runs the command with You could try redirecting stderr to a file and deducing the issue from there. The fzf \
--bind 'start:reload:exec 2>/tmp/debug.log; echo HI; foobar; echo "exit status $?" >&2' \
--with-shell 'zsh -fvxc'
cat /tmp/debug.log
+zsh:1> echo HI
+zsh:1> foobar
zsh:1: command not found: foobar
+zsh:1> echo 'exit status 127'
exit status 127 fzf \
--bind 'start:reload:exec 2>/tmp/debug.log; echo HI; grep foobar /non/existing/directory; echo "exit status $?" >&2' \
--with-shell 'zsh -fvxc'
cat /tmp/debug.log
+zsh:1> echo HI
+zsh:1> grep foobar /non/existing/directory
grep: /non/existing/directory: No such file or directory
+zsh:1> echo 'exit status 2'
exit status 2 Footnotes |
Beta Was this translation helpful? Give feedback.
-
Another way is to use the fzf --listen --header-border --bind 'start:reload:
echo foo
sleep 1
invalid-command || curl localhost:$FZF_PORT -d "change-header:Command failed"
' |
Beta Was this translation helpful? Give feedback.
-
Those are very interesting approaches, I will play around with them. Thanks for that. I actually wasnt aware of the whole A kinda nuclear solution that I found is like this: |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Hi,
I'm using
fzf
with--bind 'start:reload:some command'
and I don't know if there is a way to detect that this command, even though it generated some entries, failed and exited with a non-zero exit code. It's impossible to tell as a user, since you do get many entries.Cheers, Daniel.
Beta Was this translation helpful? Give feedback.
All reactions