mirror of
https://github.com/junegunn/fzf.git
synced 2025-11-17 07:43:39 -05:00
[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%'
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user