From 863e813928ddd6071a786b3128c82fa35cc26a69 Mon Sep 17 00:00:00 2001 From: Pete Yandell Date: Mon, 10 Aug 2015 17:20:39 +1000 Subject: [PATCH] Allow configuring which tmux binary to use. This is mostly useful for supporting tmate, which is a fork of tmux that uses a different command name. --- doc/vimux.txt | 11 +++++++++++ plugin/vimux.vim | 39 ++++++++++++++++++++++----------------- 2 files changed, 33 insertions(+), 17 deletions(-) diff --git a/doc/vimux.txt b/doc/vimux.txt index 6b2e1f1..1c49e23 100644 --- a/doc/vimux.txt +++ b/doc/vimux.txt @@ -351,5 +351,16 @@ Options: 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: diff --git a/plugin/vimux.vim b/plugin/vimux.vim index 12ae004..5d6dd34 100644 --- a/plugin/vimux.vim +++ b/plugin/vimux.vim @@ -58,7 +58,7 @@ endfunction function! VimuxSendKeys(keys) if exists("g:VimuxRunnerIndex") - call system("tmux send-keys -t ".g:VimuxRunnerIndex." ".a:keys) + call _VimuxTmux("send-keys -t ".g:VimuxRunnerIndex." ".a:keys) else echo "No vimux runner pane/window. Create one with VimuxOpenRunner" endif @@ -73,19 +73,19 @@ function! VimuxOpenRunner() if _VimuxRunnerType() == "pane" let height = _VimuxOption("g:VimuxHeight", 20) let orientation = _VimuxOption("g:VimuxOrientation", "v") - call system("tmux split-window -p ".height." -".orientation) + call _VimuxTmux("split-window -p ".height." -".orientation) elseif _VimuxRunnerType() == "window" - call system("tmux new-window") + call _VimuxTmux("new-window") endif let g:VimuxRunnerIndex = _VimuxTmuxIndex() - call system("tmux last-"._VimuxRunnerType()) + call _VimuxTmux("last-"._VimuxRunnerType()) endif endfunction function! VimuxCloseRunner() if exists("g:VimuxRunnerIndex") - call system("tmux kill-"._VimuxRunnerType()." -t ".g:VimuxRunnerIndex) + call _VimuxTmux("kill-"._VimuxRunnerType()." -t ".g:VimuxRunnerIndex) unlet g:VimuxRunnerIndex endif endfunction @@ -93,10 +93,10 @@ endfunction function! VimuxTogglePane() if exists("g:VimuxRunnerIndex") 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" 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" endif endif @@ -105,27 +105,27 @@ endfunction function! VimuxZoomRunner() if exists("g:VimuxRunnerIndex") if _VimuxRunnerType() == "pane" - call system("tmux resize-pane -Z -t ".g:VimuxRunnerIndex) + call _VimuxTmux("resize-pane -Z -t ".g:VimuxRunnerIndex) elseif _VimuxRunnerType() == "window" - call system("tmux select-window -t ".g:VimuxRunnerIndex) + call _VimuxTmux("select-window -t ".g:VimuxRunnerIndex) endif endif endfunction function! VimuxInspectRunner() - call system("tmux select-"._VimuxRunnerType()." -t ".g:VimuxRunnerIndex) - call system("tmux copy-mode") + call _VimuxTmux("select-"._VimuxRunnerType()." -t ".g:VimuxRunnerIndex) + call _VimuxTmux("copy-mode") endfunction function! VimuxScrollUpInspect() call VimuxInspectRunner() - call system("tmux last-"._VimuxRunnerType()) + call _VimuxTmux("last-"._VimuxRunnerType()) call VimuxSendKeys("C-u") endfunction function! VimuxScrollDownInspect() call VimuxInspectRunner() - call system("tmux last-"._VimuxRunnerType()) + call _VimuxTmux("last-"._VimuxRunnerType()) call VimuxSendKeys("C-d") endfunction @@ -135,7 +135,7 @@ endfunction function! VimuxClearRunnerHistory() if exists("g:VimuxRunnerIndex") - call system("tmux clear-history -t ".g:VimuxRunnerIndex) + call _VimuxTmux("clear-history -t ".g:VimuxRunnerIndex) endif endfunction @@ -145,6 +145,11 @@ function! VimuxPromptCommand(...) call VimuxRunCommand(l:command) endfunction +function! _VimuxTmux(arguments) + let l:command = _VimuxOption("g:VimuxTmuxCommand", "tmux") + return system(l:command." ".a:arguments) +endfunction + function! _VimuxTmuxSession() return _VimuxTmuxProperty("#S") endfunction @@ -166,7 +171,7 @@ function! _VimuxTmuxWindowIndex() endfunction function! _VimuxNearestIndex() - let views = split(system("tmux list-"._VimuxRunnerType()."s"), "\n") + let views = split(_VimuxTmux("list-"._VimuxRunnerType()."s"), "\n") for view in views if match(view, "(active)") == -1 @@ -190,9 +195,9 @@ function! _VimuxOption(option, default) endfunction function! _VimuxTmuxProperty(property) - return substitute(system("tmux display -p '".a:property."'"), '\n$', '', '') + return substitute(_VimuxTmux("display -p '".a:property."'"), '\n$', '', '') endfunction function! _VimuxHasRunner(index) - return match(system("tmux list-"._VimuxRunnerType()."s -a"), a:index.":") + return match(_VimuxTmux("list-"._VimuxRunnerType()."s -a"), a:index.":") endfunction