-
-
Notifications
You must be signed in to change notification settings - Fork 2.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fixed #796 #895
Fixed #796 #895
Conversation
Thanks, I like the approach. The signal handler is triggered even when fzf exits normally, so I think it's more appropriate that we clear it when it's not needed. What do you think? This version also sets the exit code properly (130) when the pane is killed. diff --git a/bin/fzf-tmux b/bin/fzf-tmux
index d7185a2..c1b3446 100755
--- a/bin/fzf-tmux
+++ b/bin/fzf-tmux
@@ -144,8 +144,13 @@ cleanup() {
kill-window -t $tmp_window \; \
resize-pane -Z
fi
+
+ if [ $# -gt 0 ]; then
+ exit 130
+ fi
}
trap cleanup EXIT SIGINT SIGTERM
+trap 'cleanup 1' SIGUSR1
envs="env TERM=$TERM "
[[ -n "$FZF_DEFAULT_OPTS" ]] && envs="$envs FZF_DEFAULT_OPTS=$(printf %q "$FZF_DEFAULT_OPTS")"
@@ -164,18 +169,22 @@ for arg in "${args[@]}"; do
opts="$opts \"$arg\""
done
+pppid=$$
+trap_set="trap 'kill -SIGUSR1 $pppid' EXIT SIGINT SIGTERM"
+trap_unset="trap - EXIT SIGINT SIGTERM"
+
if [[ -n "$term" ]] || [[ -t 0 ]]; then
cat <<< "\"$fzf\" $opts > $fifo2; echo \$? > $fifo3 $close" > $argsf
TMUX=$(echo $TMUX | cut -d , -f 1,2) tmux set-window-option synchronize-panes off \;\
set-window-option remain-on-exit off \;\
- split-window $opt "cd $(printf %q "$PWD");$envs bash $argsf" $swap \
+ split-window $opt "$trap_set;cd $(printf %q "$PWD");$envs bash $argsf;$trap_unset" $swap \
> /dev/null 2>&1
else
mkfifo $fifo1
cat <<< "\"$fzf\" $opts < $fifo1 > $fifo2; echo \$? > $fifo3 $close" > $argsf
TMUX=$(echo $TMUX | cut -d , -f 1,2) tmux set-window-option synchronize-panes off \;\
set-window-option remain-on-exit off \;\
- split-window $opt "$envs bash $argsf" $swap \
+ split-window $opt "$trap_set;$envs bash $argsf;$trap_unset" $swap \
> /dev/null 2>&1
cat <&0 > $fifo1 &
fi |
Thank you for review :) |
bin/fzf-tmux
Outdated
@@ -144,8 +144,12 @@ cleanup() { | |||
kill-window -t $tmp_window \; \ | |||
resize-pane -Z | |||
fi | |||
|
|||
if [ $# -gt 0 ]; then | |||
exit 130 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A minor nit. Can you fix the indentation here to 2 spaces?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oh. sorry.. 🙇
I'll do it right away.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No problem, thanks.
Merged, thanks for the contribution! |
Hi 🍣
I tried fix issue #796.