From bf65e8cd12b0477a916ed16fa6d9d3ff9a78c824 Mon Sep 17 00:00:00 2001 From: Junegunn Choi Date: Tue, 31 Mar 2020 22:18:09 +0900 Subject: [fzf-tmux] Add option to start fzf in tmux popup window Requires latest tmux built from source (e.g. brew install tmux --HEAD) Examples: # 50%/50% width and height on the center of the screen fzf-tmux -p # 80%/80% fzf-tmux -p80% # 80%/40% fzf-tmux -p80%,40% # Separate -w and -h fzf-tmux -w80% -h40% # 80%/40% at position (0, 0) fzf-tmux -w80% -h40% -x0 -y0 You can configure key bindings and fuzzy completion to open in tmux popup window like so: FZF_TMUX_OPTS='-p 80%' --- test/test_go.rb | 28 +++++++++++++--------------- 1 file changed, 13 insertions(+), 15 deletions(-) (limited to 'test') diff --git a/test/test_go.rb b/test/test_go.rb index a1ea33a5..108b6eb6 100755 --- a/test/test_go.rb +++ b/test/test_go.rb @@ -99,31 +99,27 @@ class Tmux go(%W[kill-window -t #{win}]) end + def focus + go(%W[select-window -t #{win}]) + end + def send_keys(*args) - target = - if args.last.is_a?(Hash) - hash = args.pop - go(%W[select-window -t #{win}]) - "#{win}.#{hash[:pane]}" - else - win - end - go(%W[send-keys -t #{target}] + args.map(&:to_s)) + go(%W[send-keys -t #{win}] + args.map(&:to_s)) end def paste(str) system('tmux', 'setb', str, ';', 'pasteb', '-t', win, ';', 'send-keys', '-t', win, 'Enter') end - def capture(pane = 0) - go(%W[capture-pane -p -t #{win}.#{pane}]).reverse.drop_while(&:empty?).reverse + def capture + go(%W[capture-pane -p -t #{win}]).reverse.drop_while(&:empty?).reverse end - def until(refresh = false, pane = 0) + def until(refresh = false) lines = nil begin wait do - lines = capture(pane) + lines = capture class << lines def counts lazy @@ -2040,9 +2036,11 @@ module CompletionTest tmux.send_keys 'C-c' # FZF_TMUX=1 + skip 'screen size too small' if `tput lines`.to_i < 15 new_shell - tmux.send_keys 'unset FZFFOOBR**', :Tab, pane: 0 - tmux.until(false, 1) { |lines| lines.match_count == 1 } + tmux.focus + tmux.send_keys 'unset FZFFOOBR**', :Tab + tmux.until { |lines| lines.match_count == 1 } tmux.send_keys :Enter tmux.until { |lines| lines[-1].include? 'unset FZFFOOBAR' } end -- cgit v1.2.3