Skip to content

Commit 40d9f74

Browse files
committed
Merge pull request #130 from notahat/master
Allow configuring which tmux binary to use.
2 parents 21d7a34 + 863e813 commit 40d9f74

File tree

2 files changed

+33
-17
lines changed

2 files changed

+33
-17
lines changed

doc/vimux.txt

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -351,5 +351,16 @@ Options:
351351

352352
Default: "pane"
353353

354+
------------------------------------------------------------------------------
355+
*VimuxTmuxCommand*
356+
2.7 g:VimuxTmuxCommand~
357+
358+
The command that Vimux runs when it calls out to tmux. It may be useful to
359+
redefine this if you're using something like tmate.
360+
361+
let g:VimuxTmuxCommand = "tmate"
362+
363+
Default: "tmux"
364+
354365
==============================================================================
355366
vim:tw=78:ts=2:sw=2:expandtab:ft=help:norl:

plugin/vimux.vim

Lines changed: 22 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ endfunction
5858

5959
function! VimuxSendKeys(keys)
6060
if exists("g:VimuxRunnerIndex")
61-
call system("tmux send-keys -t ".g:VimuxRunnerIndex." ".a:keys)
61+
call _VimuxTmux("send-keys -t ".g:VimuxRunnerIndex." ".a:keys)
6262
else
6363
echo "No vimux runner pane/window. Create one with VimuxOpenRunner"
6464
endif
@@ -73,30 +73,30 @@ function! VimuxOpenRunner()
7373
if _VimuxRunnerType() == "pane"
7474
let height = _VimuxOption("g:VimuxHeight", 20)
7575
let orientation = _VimuxOption("g:VimuxOrientation", "v")
76-
call system("tmux split-window -p ".height." -".orientation)
76+
call _VimuxTmux("split-window -p ".height." -".orientation)
7777
elseif _VimuxRunnerType() == "window"
78-
call system("tmux new-window")
78+
call _VimuxTmux("new-window")
7979
endif
8080

8181
let g:VimuxRunnerIndex = _VimuxTmuxIndex()
82-
call system("tmux last-"._VimuxRunnerType())
82+
call _VimuxTmux("last-"._VimuxRunnerType())
8383
endif
8484
endfunction
8585

8686
function! VimuxCloseRunner()
8787
if exists("g:VimuxRunnerIndex")
88-
call system("tmux kill-"._VimuxRunnerType()." -t ".g:VimuxRunnerIndex)
88+
call _VimuxTmux("kill-"._VimuxRunnerType()." -t ".g:VimuxRunnerIndex)
8989
unlet g:VimuxRunnerIndex
9090
endif
9191
endfunction
9292

9393
function! VimuxTogglePane()
9494
if exists("g:VimuxRunnerIndex")
9595
if _VimuxRunnerType() == "window"
96-
call system("tmux join-pane -d -s ".g:VimuxRunnerIndex." -p "._VimuxOption("g:VimuxHeight", 20))
96+
call _VimuxTmux("join-pane -d -s ".g:VimuxRunnerIndex." -p "._VimuxOption("g:VimuxHeight", 20))
9797
let g:VimuxRunnerType = "pane"
9898
elseif _VimuxRunnerType() == "pane"
99-
let g:VimuxRunnerIndex=substitute(system("tmux break-pane -d -t ".g:VimuxRunnerIndex." -P -F '#{window_index}'"), "\n", "", "")
99+
let g:VimuxRunnerIndex=substitute(_VimuxTmux("break-pane -d -t ".g:VimuxRunnerIndex." -P -F '#{window_index}'"), "\n", "", "")
100100
let g:VimuxRunnerType = "window"
101101
endif
102102
endif
@@ -105,27 +105,27 @@ endfunction
105105
function! VimuxZoomRunner()
106106
if exists("g:VimuxRunnerIndex")
107107
if _VimuxRunnerType() == "pane"
108-
call system("tmux resize-pane -Z -t ".g:VimuxRunnerIndex)
108+
call _VimuxTmux("resize-pane -Z -t ".g:VimuxRunnerIndex)
109109
elseif _VimuxRunnerType() == "window"
110-
call system("tmux select-window -t ".g:VimuxRunnerIndex)
110+
call _VimuxTmux("select-window -t ".g:VimuxRunnerIndex)
111111
endif
112112
endif
113113
endfunction
114114

115115
function! VimuxInspectRunner()
116-
call system("tmux select-"._VimuxRunnerType()." -t ".g:VimuxRunnerIndex)
117-
call system("tmux copy-mode")
116+
call _VimuxTmux("select-"._VimuxRunnerType()." -t ".g:VimuxRunnerIndex)
117+
call _VimuxTmux("copy-mode")
118118
endfunction
119119

120120
function! VimuxScrollUpInspect()
121121
call VimuxInspectRunner()
122-
call system("tmux last-"._VimuxRunnerType())
122+
call _VimuxTmux("last-"._VimuxRunnerType())
123123
call VimuxSendKeys("C-u")
124124
endfunction
125125

126126
function! VimuxScrollDownInspect()
127127
call VimuxInspectRunner()
128-
call system("tmux last-"._VimuxRunnerType())
128+
call _VimuxTmux("last-"._VimuxRunnerType())
129129
call VimuxSendKeys("C-d")
130130
endfunction
131131

@@ -135,7 +135,7 @@ endfunction
135135

136136
function! VimuxClearRunnerHistory()
137137
if exists("g:VimuxRunnerIndex")
138-
call system("tmux clear-history -t ".g:VimuxRunnerIndex)
138+
call _VimuxTmux("clear-history -t ".g:VimuxRunnerIndex)
139139
endif
140140
endfunction
141141

@@ -145,6 +145,11 @@ function! VimuxPromptCommand(...)
145145
call VimuxRunCommand(l:command)
146146
endfunction
147147

148+
function! _VimuxTmux(arguments)
149+
let l:command = _VimuxOption("g:VimuxTmuxCommand", "tmux")
150+
return system(l:command." ".a:arguments)
151+
endfunction
152+
148153
function! _VimuxTmuxSession()
149154
return _VimuxTmuxProperty("#S")
150155
endfunction
@@ -166,7 +171,7 @@ function! _VimuxTmuxWindowIndex()
166171
endfunction
167172

168173
function! _VimuxNearestIndex()
169-
let views = split(system("tmux list-"._VimuxRunnerType()."s"), "\n")
174+
let views = split(_VimuxTmux("list-"._VimuxRunnerType()."s"), "\n")
170175

171176
for view in views
172177
if match(view, "(active)") == -1
@@ -190,9 +195,9 @@ function! _VimuxOption(option, default)
190195
endfunction
191196

192197
function! _VimuxTmuxProperty(property)
193-
return substitute(system("tmux display -p '".a:property."'"), '\n$', '', '')
198+
return substitute(_VimuxTmux("display -p '".a:property."'"), '\n$', '', '')
194199
endfunction
195200

196201
function! _VimuxHasRunner(index)
197-
return match(system("tmux list-"._VimuxRunnerType()."s -a"), a:index.":")
202+
return match(_VimuxTmux("list-"._VimuxRunnerType()."s -a"), a:index.":")
198203
endfunction

0 commit comments

Comments
 (0)