From ddd2a109e4746160d1b88a438e3ea8bfa1c78e48 Mon Sep 17 00:00:00 2001 From: Heinrich Kruger Date: Thu, 3 May 2018 20:25:15 +0100 Subject: [PATCH] [fzf-tmux] Restore tmux window options (#1272) Restore the original values of 'remain-on-exit' and 'synchronize-panes' options when exiting 'fzf-tmux'. --- bin/fzf-tmux | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/bin/fzf-tmux b/bin/fzf-tmux index 79407e60..1dc2a04a 100755 --- a/bin/fzf-tmux +++ b/bin/fzf-tmux @@ -136,6 +136,11 @@ fifo3="${TMPDIR:-/tmp}/fzf-fifo3-$id" cleanup() { \rm -f $argsf $fifo1 $fifo2 $fifo3 + # Restore tmux window options + if [[ "${#tmux_win_opts[@]}" -gt 0 ]]; then + eval "tmux ${tmux_win_opts[@]}" + fi + # Remove temp window if we were zoomed if [[ -n "$zoomed" ]]; then tmux display-message -p "#{window_id}" > /dev/null @@ -174,6 +179,8 @@ pppid=$$ echo -n "trap 'kill -SIGUSR1 -$pppid' EXIT SIGINT SIGTERM;" > $argsf close="; trap - EXIT SIGINT SIGTERM $close" +tmux_win_opts=( $(tmux show-window-options remain-on-exit \; show-window-options synchronize-panes | sed 's/^/set-window-option /; s/$/ \\;/') ) + 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 \;\