Add initialCommand option for runner startup
This commit is contained in:
parent
41bcb5b887
commit
fa3f90375d
@ -20,6 +20,8 @@ endfunction
|
|||||||
function! s:InitializeVariables()
|
function! s:InitializeVariables()
|
||||||
call s:InitVariable("g:VtrPercentage", 20)
|
call s:InitVariable("g:VtrPercentage", 20)
|
||||||
call s:InitVariable("g:VtrOrientation", "v")
|
call s:InitVariable("g:VtrOrientation", "v")
|
||||||
|
call s:InitVariable("g:VtrInitialCommand", "")
|
||||||
|
call s:InitVariable("g:VtrClearBeforeSend", 1)
|
||||||
endfunction
|
endfunction
|
||||||
call s:InitializeVariables()
|
call s:InitializeVariables()
|
||||||
|
|
||||||
@ -29,6 +31,11 @@ function! s:OpenRunnerPane()
|
|||||||
call s:SendTmuxCommand(cmd)
|
call s:SendTmuxCommand(cmd)
|
||||||
let s:runner_pane = s:ActiveTmuxPaneNumber()
|
let s:runner_pane = s:ActiveTmuxPaneNumber()
|
||||||
call s:FocusVimPane()
|
call s:FocusVimPane()
|
||||||
|
if g:VtrInitialCommand != ""
|
||||||
|
call s:SendKeys(g:VtrInitialCommand)
|
||||||
|
call s:SendEnterSequence()
|
||||||
|
call s:SendClearSequence()
|
||||||
|
endif
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! s:KillRunnerPane()
|
function! s:KillRunnerPane()
|
||||||
@ -69,15 +76,11 @@ function! s:TargetedTmuxCommand(command, target_pane)
|
|||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! s:SendEnterSequence()
|
function! s:SendEnterSequence()
|
||||||
let targeted_cmd = s:TargetedTmuxCommand("send-keys", s:runner_pane)
|
call s:SendKeys("Enter")
|
||||||
let enter_sequence = targeted_cmd . " Enter"
|
|
||||||
call s:SendTmuxCommand(enter_sequence)
|
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! s:SendClearSequence()
|
function! s:SendClearSequence()
|
||||||
let targeted_cmd = s:TargetedTmuxCommand("send-keys", s:runner_pane)
|
call s:SendKeys("clear")
|
||||||
let enter_sequence = targeted_cmd . " clear"
|
|
||||||
call s:SendTmuxCommand(enter_sequence)
|
|
||||||
call s:SendEnterSequence()
|
call s:SendEnterSequence()
|
||||||
sleep 50m
|
sleep 50m
|
||||||
endfunction
|
endfunction
|
||||||
@ -104,19 +107,30 @@ endfunction
|
|||||||
function! s:RotateRunner()
|
function! s:RotateRunner()
|
||||||
let temp_window = s:BreakRunnerPaneToTempWindow()
|
let temp_window = s:BreakRunnerPaneToTempWindow()
|
||||||
call s:ToggleOrientationVariable()
|
call s:ToggleOrientationVariable()
|
||||||
let join_cmd = join(["join-pane", "-s", ":".temp_window.".0", "-p", g:VtrPercentage, "-".g:VtrOrientation])
|
let join_cmd = join(["join-pane", "-s", ":".temp_window.".0",
|
||||||
|
\ "-p", g:VtrPercentage, "-".g:VtrOrientation])
|
||||||
echom join_cmd
|
echom join_cmd
|
||||||
call s:SendTmuxCommand(join_cmd)
|
call s:SendTmuxCommand(join_cmd)
|
||||||
call s:FocusVimPane()
|
call s:FocusVimPane()
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! s:SendCommandToRunner()
|
function! s:SendKeys(keys)
|
||||||
echohl String
|
|
||||||
let user_command = shellescape(input("Command to run: "))
|
|
||||||
let targeted_cmd = s:TargetedTmuxCommand("send-keys", s:runner_pane)
|
let targeted_cmd = s:TargetedTmuxCommand("send-keys", s:runner_pane)
|
||||||
let full_command = join([targeted_cmd, user_command])
|
let full_command = join([targeted_cmd, a:keys])
|
||||||
call s:SendClearSequence()
|
|
||||||
call s:SendTmuxCommand(full_command)
|
call s:SendTmuxCommand(full_command)
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
function! s:HighlightedInput(prompt)
|
||||||
|
echohl String | let input = shellescape(input(a:prompt)) | echohl None
|
||||||
|
return input
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
function! s:SendCommandToRunner()
|
||||||
|
let user_command = s:HighlightedInput("Command to send: ")
|
||||||
|
if g:VtrClearBeforeSend
|
||||||
|
call s:SendClearSequence()
|
||||||
|
endif
|
||||||
|
call s:SendKeys(user_command)
|
||||||
call s:SendEnterSequence()
|
call s:SendEnterSequence()
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user