@@ -50,7 +50,7 @@ endfunction
5050
5151function ! VimuxSendKeys (keys )
5252 if exists (" g:VimuxRunnerIndex" )
53- call system ( " tmux send-keys -t " .g: VimuxRunnerIndex ." " .a: keys )
53+ call _VimuxTmux ( " send-keys -t " .g: VimuxRunnerIndex ." " .a: keys )
5454 else
5555 echo " No vimux runner pane/window. Create one with VimuxOpenRunner"
5656 endif
@@ -65,30 +65,30 @@ function! VimuxOpenRunner()
6565 if _VimuxRunnerType () == " pane"
6666 let height = _VimuxOption (" g:VimuxHeight" , 20 )
6767 let orientation = _VimuxOption (" g:VimuxOrientation" , " v" )
68- call system ( " tmux split-window -p " .height." -" .orientation)
68+ call _VimuxTmux ( " split-window -p " .height." -" .orientation)
6969 elseif _VimuxRunnerType () == " window"
70- call system ( " tmux new-window" )
70+ call _VimuxTmux ( " new-window" )
7171 endif
7272
7373 let g: VimuxRunnerIndex = _VimuxTmuxIndex ()
74- call system ( " tmux last-" ._VimuxRunnerType ())
74+ call _VimuxTmux ( " last-" ._VimuxRunnerType ())
7575 endif
7676endfunction
7777
7878function ! VimuxCloseRunner ()
7979 if exists (" g:VimuxRunnerIndex" )
80- call system ( " tmux kill-" ._VimuxRunnerType ()." -t " .g: VimuxRunnerIndex )
80+ call _VimuxTmux ( " kill-" ._VimuxRunnerType ()." -t " .g: VimuxRunnerIndex )
8181 unlet g: VimuxRunnerIndex
8282 endif
8383endfunction
8484
8585function ! VimuxTogglePane ()
8686 if exists (" g:VimuxRunnerIndex" )
8787 if _VimuxRunnerType () == " window"
88- call system ( " tmux join-pane -d -s " .g: VimuxRunnerIndex ." -p " ._VimuxOption (" g:VimuxHeight" , 20 ))
88+ call _VimuxTmux ( " join-pane -d -s " .g: VimuxRunnerIndex ." -p " ._VimuxOption (" g:VimuxHeight" , 20 ))
8989 let g: VimuxRunnerType = " pane"
9090 elseif _VimuxRunnerType () == " pane"
91- let g: VimuxRunnerIndex= substitute (system ( " tmux break-pane -d -t " .g: VimuxRunnerIndex ." -P -F '#{window_index}'" ), " \n " , " " , " " )
91+ let g: VimuxRunnerIndex= substitute (_VimuxTmux ( " break-pane -d -t " .g: VimuxRunnerIndex ." -P -F '#{window_index}'" ), " \n " , " " , " " )
9292 let g: VimuxRunnerType = " window"
9393 endif
9494 endif
@@ -97,27 +97,27 @@ endfunction
9797function ! VimuxZoomRunner ()
9898 if exists (" g:VimuxRunnerIndex" )
9999 if _VimuxRunnerType () == " pane"
100- call system ( " tmux resize-pane -Z -t " .g: VimuxRunnerIndex )
100+ call _VimuxTmux ( " resize-pane -Z -t " .g: VimuxRunnerIndex )
101101 elseif _VimuxRunnerType () == " window"
102- call system ( " tmux select-window -t " .g: VimuxRunnerIndex )
102+ call _VimuxTmux ( " select-window -t " .g: VimuxRunnerIndex )
103103 endif
104104 endif
105105endfunction
106106
107107function ! VimuxInspectRunner ()
108- call system ( " tmux select-" ._VimuxRunnerType ()." -t " .g: VimuxRunnerIndex )
109- call system ( " tmux copy-mode" )
108+ call _VimuxTmux ( " select-" ._VimuxRunnerType ()." -t " .g: VimuxRunnerIndex )
109+ call _VimuxTmux ( " copy-mode" )
110110endfunction
111111
112112function ! VimuxScrollUpInspect ()
113113 call VimuxInspectRunner ()
114- call system ( " tmux last-" ._VimuxRunnerType ())
114+ call _VimuxTmux ( " last-" ._VimuxRunnerType ())
115115 call VimuxSendKeys (" C-u" )
116116endfunction
117117
118118function ! VimuxScrollDownInspect ()
119119 call VimuxInspectRunner ()
120- call system ( " tmux last-" ._VimuxRunnerType ())
120+ call _VimuxTmux ( " last-" ._VimuxRunnerType ())
121121 call VimuxSendKeys (" C-d" )
122122endfunction
123123
@@ -127,7 +127,7 @@ endfunction
127127
128128function ! VimuxClearRunnerHistory ()
129129 if exists (" g:VimuxRunnerIndex" )
130- call system ( " tmux clear-history -t " .g: VimuxRunnerIndex )
130+ call _VimuxTmux ( " clear-history -t " .g: VimuxRunnerIndex )
131131 endif
132132endfunction
133133
@@ -158,7 +158,7 @@ function! _VimuxTmuxWindowIndex()
158158endfunction
159159
160160function ! _VimuxNearestIndex ()
161- let views = split (system ( " tmux list-" ._VimuxRunnerType ()." s" ), " \n " )
161+ let views = split (_VimuxTmux ( " list-" ._VimuxRunnerType ()." s" ), " \n " )
162162
163163 for view in views
164164 if match (view , " (active)" ) == -1
@@ -182,9 +182,18 @@ function! _VimuxOption(option, default)
182182endfunction
183183
184184function ! _VimuxTmuxProperty (property)
185- return substitute (system ( " tmux display -p '" .a: property ." '" ), ' \n$' , ' ' , ' ' )
185+ return substitute (_VimuxTmux ( " display -p '" .a: property ." '" ), ' \n$' , ' ' , ' ' )
186186endfunction
187187
188188function ! _VimuxHasRunner (index )
189- return match (system (" tmux list-" ._VimuxRunnerType ()." s -a" ), a: index ." :" )
189+ return match (_VimuxTmux (" list-" ._VimuxRunnerType ()." s -a" ), a: index ." :" )
190+ endfunction
191+
192+ function ! _VimuxTmux (... )
193+ let command = " tmux"
194+ if exists (" g:VimuxSocketPath" )
195+ let command .= ' -S ' . g: VimuxSocketPath
196+ endif
197+ let command .= ' ' . join (a: 000 , ' ' )
198+ return system (command )
190199endfunction
0 commit comments