summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJunegunn Choi <junegunn.c@gmail.com>2015-12-08 10:56:06 +0900
committerJunegunn Choi <junegunn.c@gmail.com>2015-12-08 10:56:06 +0900
commit971ea2217c24e86b8b80fe64bcf53ca9a0b6316c (patch)
tree242d55486b78297de341a78658063e10aadc0882
parenta1db64e7b1588bc44dccd3b3895a075977f70ce4 (diff)
parentd513a210c6b59106d899c8e3287e24a3ffc5956d (diff)
Merge pull request #433 from pokey/master
Support fzf-tmux when zoomed
-rwxr-xr-xbin/fzf-tmux18
-rw-r--r--plugin/fzf.vim8
2 files changed, 19 insertions, 7 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
diff --git a/plugin/fzf.vim b/plugin/fzf.vim
index fddab518..d8106935 100644
--- a/plugin/fzf.vim
+++ b/plugin/fzf.vim
@@ -52,17 +52,13 @@ function! s:fzf_exec()
return s:exec
endfunction
-function! s:tmux_not_zoomed()
- return system('tmux list-panes -F "#F"') !~# 'Z'
-endfunction
-
function! s:tmux_enabled()
if has('gui_running')
return 0
endif
if exists('s:tmux')
- return s:tmux && s:tmux_not_zoomed()
+ return s:tmux
endif
let s:tmux = 0
@@ -70,7 +66,7 @@ function! s:tmux_enabled()
let output = system('tmux -V')
let s:tmux = !v:shell_error && output >= 'tmux 1.7'
endif
- return s:tmux && s:tmux_not_zoomed()
+ return s:tmux
endfunction
function! s:shellesc(arg)