Merge pull request #130 from notahat/master

Allow configuring which tmux binary to use.
fix-tmux-next-3dot4
Ben Mills 9 years ago
commit 40d9f74db6

@ -351,5 +351,16 @@ Options:
Default: "pane" Default: "pane"
------------------------------------------------------------------------------
*VimuxTmuxCommand*
2.7 g:VimuxTmuxCommand~
The command that Vimux runs when it calls out to tmux. It may be useful to
redefine this if you're using something like tmate.
let g:VimuxTmuxCommand = "tmate"
Default: "tmux"
============================================================================== ==============================================================================
vim:tw=78:ts=2:sw=2:expandtab:ft=help:norl: vim:tw=78:ts=2:sw=2:expandtab:ft=help:norl:

@ -58,7 +58,7 @@ endfunction
function! VimuxSendKeys(keys) function! VimuxSendKeys(keys)
if exists("g:VimuxRunnerIndex") if exists("g:VimuxRunnerIndex")
call system("tmux send-keys -t ".g:VimuxRunnerIndex." ".a:keys) call _VimuxTmux("send-keys -t ".g:VimuxRunnerIndex." ".a:keys)
else else
echo "No vimux runner pane/window. Create one with VimuxOpenRunner" echo "No vimux runner pane/window. Create one with VimuxOpenRunner"
endif endif
@ -73,19 +73,19 @@ function! VimuxOpenRunner()
if _VimuxRunnerType() == "pane" if _VimuxRunnerType() == "pane"
let height = _VimuxOption("g:VimuxHeight", 20) let height = _VimuxOption("g:VimuxHeight", 20)
let orientation = _VimuxOption("g:VimuxOrientation", "v") let orientation = _VimuxOption("g:VimuxOrientation", "v")
call system("tmux split-window -p ".height." -".orientation) call _VimuxTmux("split-window -p ".height." -".orientation)
elseif _VimuxRunnerType() == "window" elseif _VimuxRunnerType() == "window"
call system("tmux new-window") call _VimuxTmux("new-window")
endif endif
let g:VimuxRunnerIndex = _VimuxTmuxIndex() let g:VimuxRunnerIndex = _VimuxTmuxIndex()
call system("tmux last-"._VimuxRunnerType()) call _VimuxTmux("last-"._VimuxRunnerType())
endif endif
endfunction endfunction
function! VimuxCloseRunner() function! VimuxCloseRunner()
if exists("g:VimuxRunnerIndex") if exists("g:VimuxRunnerIndex")
call system("tmux kill-"._VimuxRunnerType()." -t ".g:VimuxRunnerIndex) call _VimuxTmux("kill-"._VimuxRunnerType()." -t ".g:VimuxRunnerIndex)
unlet g:VimuxRunnerIndex unlet g:VimuxRunnerIndex
endif endif
endfunction endfunction
@ -93,10 +93,10 @@ endfunction
function! VimuxTogglePane() function! VimuxTogglePane()
if exists("g:VimuxRunnerIndex") if exists("g:VimuxRunnerIndex")
if _VimuxRunnerType() == "window" if _VimuxRunnerType() == "window"
call system("tmux join-pane -d -s ".g:VimuxRunnerIndex." -p "._VimuxOption("g:VimuxHeight", 20)) call _VimuxTmux("join-pane -d -s ".g:VimuxRunnerIndex." -p "._VimuxOption("g:VimuxHeight", 20))
let g:VimuxRunnerType = "pane" let g:VimuxRunnerType = "pane"
elseif _VimuxRunnerType() == "pane" elseif _VimuxRunnerType() == "pane"
let g:VimuxRunnerIndex=substitute(system("tmux break-pane -d -t ".g:VimuxRunnerIndex." -P -F '#{window_index}'"), "\n", "", "") let g:VimuxRunnerIndex=substitute(_VimuxTmux("break-pane -d -t ".g:VimuxRunnerIndex." -P -F '#{window_index}'"), "\n", "", "")
let g:VimuxRunnerType = "window" let g:VimuxRunnerType = "window"
endif endif
endif endif
@ -105,27 +105,27 @@ endfunction
function! VimuxZoomRunner() function! VimuxZoomRunner()
if exists("g:VimuxRunnerIndex") if exists("g:VimuxRunnerIndex")
if _VimuxRunnerType() == "pane" if _VimuxRunnerType() == "pane"
call system("tmux resize-pane -Z -t ".g:VimuxRunnerIndex) call _VimuxTmux("resize-pane -Z -t ".g:VimuxRunnerIndex)
elseif _VimuxRunnerType() == "window" elseif _VimuxRunnerType() == "window"
call system("tmux select-window -t ".g:VimuxRunnerIndex) call _VimuxTmux("select-window -t ".g:VimuxRunnerIndex)
endif endif
endif endif
endfunction endfunction
function! VimuxInspectRunner() function! VimuxInspectRunner()
call system("tmux select-"._VimuxRunnerType()." -t ".g:VimuxRunnerIndex) call _VimuxTmux("select-"._VimuxRunnerType()." -t ".g:VimuxRunnerIndex)
call system("tmux copy-mode") call _VimuxTmux("copy-mode")
endfunction endfunction
function! VimuxScrollUpInspect() function! VimuxScrollUpInspect()
call VimuxInspectRunner() call VimuxInspectRunner()
call system("tmux last-"._VimuxRunnerType()) call _VimuxTmux("last-"._VimuxRunnerType())
call VimuxSendKeys("C-u") call VimuxSendKeys("C-u")
endfunction endfunction
function! VimuxScrollDownInspect() function! VimuxScrollDownInspect()
call VimuxInspectRunner() call VimuxInspectRunner()
call system("tmux last-"._VimuxRunnerType()) call _VimuxTmux("last-"._VimuxRunnerType())
call VimuxSendKeys("C-d") call VimuxSendKeys("C-d")
endfunction endfunction
@ -135,7 +135,7 @@ endfunction
function! VimuxClearRunnerHistory() function! VimuxClearRunnerHistory()
if exists("g:VimuxRunnerIndex") if exists("g:VimuxRunnerIndex")
call system("tmux clear-history -t ".g:VimuxRunnerIndex) call _VimuxTmux("clear-history -t ".g:VimuxRunnerIndex)
endif endif
endfunction endfunction
@ -145,6 +145,11 @@ function! VimuxPromptCommand(...)
call VimuxRunCommand(l:command) call VimuxRunCommand(l:command)
endfunction endfunction
function! _VimuxTmux(arguments)
let l:command = _VimuxOption("g:VimuxTmuxCommand", "tmux")
return system(l:command." ".a:arguments)
endfunction
function! _VimuxTmuxSession() function! _VimuxTmuxSession()
return _VimuxTmuxProperty("#S") return _VimuxTmuxProperty("#S")
endfunction endfunction
@ -166,7 +171,7 @@ function! _VimuxTmuxWindowIndex()
endfunction endfunction
function! _VimuxNearestIndex() function! _VimuxNearestIndex()
let views = split(system("tmux list-"._VimuxRunnerType()."s"), "\n") let views = split(_VimuxTmux("list-"._VimuxRunnerType()."s"), "\n")
for view in views for view in views
if match(view, "(active)") == -1 if match(view, "(active)") == -1
@ -190,9 +195,9 @@ function! _VimuxOption(option, default)
endfunction endfunction
function! _VimuxTmuxProperty(property) function! _VimuxTmuxProperty(property)
return substitute(system("tmux display -p '".a:property."'"), '\n$', '', '') return substitute(_VimuxTmux("display -p '".a:property."'"), '\n$', '', '')
endfunction endfunction
function! _VimuxHasRunner(index) function! _VimuxHasRunner(index)
return match(system("tmux list-"._VimuxRunnerType()."s -a"), a:index.":") return match(_VimuxTmux("list-"._VimuxRunnerType()."s -a"), a:index.":")
endfunction endfunction

Loading…
Cancel
Save