@@ -50,7 +50,7 @@ endfunction
50
50
51
51
function ! VimuxSendKeys (keys )
52
52
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 )
54
54
else
55
55
echo " No vimux runner pane/window. Create one with VimuxOpenRunner"
56
56
endif
@@ -65,30 +65,30 @@ function! VimuxOpenRunner()
65
65
if _VimuxRunnerType () == " pane"
66
66
let height = _VimuxOption (" g:VimuxHeight" , 20 )
67
67
let orientation = _VimuxOption (" g:VimuxOrientation" , " v" )
68
- call system ( " tmux split-window -p " .height." -" .orientation)
68
+ call _VimuxTmux ( " split-window -p " .height." -" .orientation)
69
69
elseif _VimuxRunnerType () == " window"
70
- call system ( " tmux new-window" )
70
+ call _VimuxTmux ( " new-window" )
71
71
endif
72
72
73
73
let g: VimuxRunnerIndex = _VimuxTmuxIndex ()
74
- call system ( " tmux last-" ._VimuxRunnerType ())
74
+ call _VimuxTmux ( " last-" ._VimuxRunnerType ())
75
75
endif
76
76
endfunction
77
77
78
78
function ! VimuxCloseRunner ()
79
79
if exists (" g:VimuxRunnerIndex" )
80
- call system ( " tmux kill-" ._VimuxRunnerType ()." -t " .g: VimuxRunnerIndex )
80
+ call _VimuxTmux ( " kill-" ._VimuxRunnerType ()." -t " .g: VimuxRunnerIndex )
81
81
unlet g: VimuxRunnerIndex
82
82
endif
83
83
endfunction
84
84
85
85
function ! VimuxTogglePane ()
86
86
if exists (" g:VimuxRunnerIndex" )
87
87
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 ))
89
89
let g: VimuxRunnerType = " pane"
90
90
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 " , " " , " " )
92
92
let g: VimuxRunnerType = " window"
93
93
endif
94
94
endif
@@ -97,27 +97,27 @@ endfunction
97
97
function ! VimuxZoomRunner ()
98
98
if exists (" g:VimuxRunnerIndex" )
99
99
if _VimuxRunnerType () == " pane"
100
- call system ( " tmux resize-pane -Z -t " .g: VimuxRunnerIndex )
100
+ call _VimuxTmux ( " resize-pane -Z -t " .g: VimuxRunnerIndex )
101
101
elseif _VimuxRunnerType () == " window"
102
- call system ( " tmux select-window -t " .g: VimuxRunnerIndex )
102
+ call _VimuxTmux ( " select-window -t " .g: VimuxRunnerIndex )
103
103
endif
104
104
endif
105
105
endfunction
106
106
107
107
function ! 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" )
110
110
endfunction
111
111
112
112
function ! VimuxScrollUpInspect ()
113
113
call VimuxInspectRunner ()
114
- call system ( " tmux last-" ._VimuxRunnerType ())
114
+ call _VimuxTmux ( " last-" ._VimuxRunnerType ())
115
115
call VimuxSendKeys (" C-u" )
116
116
endfunction
117
117
118
118
function ! VimuxScrollDownInspect ()
119
119
call VimuxInspectRunner ()
120
- call system ( " tmux last-" ._VimuxRunnerType ())
120
+ call _VimuxTmux ( " last-" ._VimuxRunnerType ())
121
121
call VimuxSendKeys (" C-d" )
122
122
endfunction
123
123
@@ -127,7 +127,7 @@ endfunction
127
127
128
128
function ! VimuxClearRunnerHistory ()
129
129
if exists (" g:VimuxRunnerIndex" )
130
- call system ( " tmux clear-history -t " .g: VimuxRunnerIndex )
130
+ call _VimuxTmux ( " clear-history -t " .g: VimuxRunnerIndex )
131
131
endif
132
132
endfunction
133
133
@@ -158,7 +158,7 @@ function! _VimuxTmuxWindowIndex()
158
158
endfunction
159
159
160
160
function ! _VimuxNearestIndex ()
161
- let views = split (system ( " tmux list-" ._VimuxRunnerType ()." s" ), " \n " )
161
+ let views = split (_VimuxTmux ( " list-" ._VimuxRunnerType ()." s" ), " \n " )
162
162
163
163
for view in views
164
164
if match (view , " (active)" ) == -1
@@ -182,9 +182,18 @@ function! _VimuxOption(option, default)
182
182
endfunction
183
183
184
184
function ! _VimuxTmuxProperty (property)
185
- return substitute (system ( " tmux display -p '" .a: property ." '" ), ' \n$' , ' ' , ' ' )
185
+ return substitute (_VimuxTmux ( " display -p '" .a: property ." '" ), ' \n$' , ' ' , ' ' )
186
186
endfunction
187
187
188
188
function ! _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 )
190
199
endfunction
0 commit comments