summaryrefslogtreecommitdiffstats
path: root/bin
diff options
context:
space:
mode:
authorPokey Rule <pokey.rule@gmail.com>2015-12-07 17:45:22 -0800
committerPokey Rule <pokey.rule@gmail.com>2015-12-07 17:45:22 -0800
commitd513a210c6b59106d899c8e3287e24a3ffc5956d (patch)
tree242d55486b78297de341a78658063e10aadc0882 /bin
parenta1db64e7b1588bc44dccd3b3895a075977f70ce4 (diff)
Support fzf-tmux when zoomed
Diffstat (limited to 'bin')
-rwxr-xr-xbin/fzf-tmux18
1 files changed, 17 insertions, 1 deletions
diff --git a/bin/fzf-tmux b/bin/fzf-tmux
index 1085b963..f882f8c5 100755
--- a/bin/fzf-tmux
+++ b/bin/fzf-tmux
@@ -82,11 +82,19 @@ while [ $# -gt 0 ]; do
shift
done
-if [ -z "$TMUX_PANE" ] || tmux list-panes -F '#F' | grep -q Z; then
+if [ -z "$TMUX_PANE" ]; then
fzf "${args[@]}"
exit $?
fi
+# Handle zoomed tmux pane by moving it to a temp window
+if tmux list-panes -F '#F' | grep -q Z; then
+ zoomed=1
+ original_window=$(tmux display-message -p "#{window_id}")
+ tmp_window=$(tmux new-window -d -P -F "#{window_id}" "bash -c 'while :; do for c in \\| / - \\\\; do sleep 0.2; printf \"\\r\$c fzf-tmux is running\\r\"; done; done'")
+ tmux swap-pane -t $tmp_window \; select-window -t $tmp_window
+fi
+
set -e
# Clean up named pipes on exit
@@ -97,6 +105,14 @@ fifo2="${TMPDIR:-/tmp}/fzf-fifo2-$id"
fifo3="${TMPDIR:-/tmp}/fzf-fifo3-$id"
cleanup() {
rm -f $argsf $fifo1 $fifo2 $fifo3
+
+ # Remove temp window if we were zoomed
+ if [ -n "$zoomed" ]; then
+ tmux swap-pane -t $original_window \; \
+ select-window -t $original_window \; \
+ kill-window -t $tmp_window \; \
+ resize-pane -Z
+ fi
}
trap cleanup EXIT SIGINT SIGTERM