diff options
author | Junegunn Choi <junegunn.c@gmail.com> | 2020-03-31 22:18:09 +0900 |
---|---|---|
committer | Junegunn Choi <junegunn.c@gmail.com> | 2020-04-03 13:23:15 +0900 |
commit | bf65e8cd12b0477a916ed16fa6d9d3ff9a78c824 (patch) | |
tree | b2717ffe44d0d548a63359e5d18659bf6bb02a17 /test | |
parent | 0f5c6e8f040833ca632bb5ff345542879769225c (diff) |
[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%'
Diffstat (limited to 'test')
-rwxr-xr-x | test/test_go.rb | 28 |
1 files changed, 13 insertions, 15 deletions
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 |