Exit copy-mode before running a command in the runner pane. Fixes #3

1.0.0rc1
benmills 12 years ago
parent d189f2b99c
commit c4a0836dfa

@ -91,18 +91,26 @@ class TmuxSession
end
def inspect_runner
run("select-pane -t #{target(:pane => runner_pane)}")
run("copy-mode")
_run("select-pane -t #{target(:pane => runner_pane)}")
_run("copy-mode")
Vim.command("let g:_VimTmuxInspecting = 1")
end
def stop_inspecting_runner
if Vim.evaluate('exists("g:_VimTmuxInspecting")') != 0
_run("send-keys -t #{target(:pane => runner_pane)} q")
Vim.command("unlet g:_VimTmuxInspecting")
end
end
def current_panes
run('list-panes').split("\n").map do |line|
_run('list-panes').split("\n").map do |line|
line.split(':').first
end
end
def active_pane_id
run('list-panes').split("\n").map do |line|
_run('list-panes').split("\n").map do |line|
return line.split[-2] if line =~ /\(active\)/
end
end
@ -113,12 +121,12 @@ class TmuxSession
def runner_pane
if @runner_pane.nil?
run("split-window -p #{height}")
_run("split-window -p #{height}")
@runner_pane = active_pane_id
Vim.command("let g:_VimTmuxRunnerPane = '#{@runner_pane}'")
end
run('list-panes').split("\n").map do |line|
_run('list-panes').split("\n").map do |line|
return line.split(':').first if line =~ /#{@runner_pane}/
end
@ -128,30 +136,33 @@ class TmuxSession
end
def interrupt_runner
run("send-keys -t #{target(:pane => runner_pane)} ^c")
stop_inspecting_runner
_run("send-keys -t #{target(:pane => runner_pane)} ^c")
end
def run_shell_command(command)
send_command(command, target(:pane => runner_pane))
move_up_pane
stop_inspecting_runner
_send_command(command, target(:pane => runner_pane))
_move_up_pane
end
def close_other_panes
# if run("list-panes").split("\n").length > 1
run("kill-pane -a")
# end
stop_inspecting_runner
if _run("list-panes").split("\n").length > 1
_run("kill-pane -a")
end
end
def move_up_pane
run("select-pane -t #{target}")
def _move_up_pane
_run("select-pane -t #{target}")
end
def send_command(command, target)
run("send-keys -t #{target} '#{command.gsub("'", "\'")}'")
run("send-keys -t #{target} Enter")
def _send_command(command, target)
_run("send-keys -t #{target} '#{command.gsub("'", "\'")}'")
_run("send-keys -t #{target} Enter")
end
def run(command)
def _run(command)
`tmux #{command}`
end
end
@ -166,7 +177,7 @@ class CurrentTmuxSession < TmuxSession
end
def get_property(match, type)
run("list-#{type.to_s}").split("\n").each do |line|
_run("list-#{type.to_s}").split("\n").each do |line|
return line.split(':').first if line =~ /\(#{match.to_s}\)/
end
end

Loading…
Cancel
Save