Skip to content

Commit 5b17916

Browse files
Gerhard HellmannGerhard Siegesmund
andauthored
Add option to expand VimuxPromptCommand arguments (#166)
Co-authored-by: Gerhard Siegesmund <[email protected]>
1 parent 3bfe0ea commit 5b17916

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

doc/vimux.txt

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -400,5 +400,21 @@ you're using panes or windows, and your version of tmux.
400400

401401
Default: "tmux"
402402

403+
------------------------------------------------------------------------------
404+
VimuxExpandCommand
405+
4.10 g:VimuxExpandCommand~
406+
407+
Should the command given at the prompt via VimuxPromptCommand be expanded
408+
using expand(). 1 to expand the string.
409+
410+
Unfortunately expand() only expands % (etc.) if the string starts with that
411+
character. So the command is split at spaces and then rejoined after
412+
expansion. With this simple approach things like "%:h/test.xml" are not
413+
possible.
414+
415+
let g:VimuxExpandCommand = 1
416+
417+
Default: 0
418+
403419
==============================================================================
404420
vim:tw=78:ts=2:sw=2:expandtab:ft=help:norl:

plugin/vimux.vim

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ let g:VimuxRunnerName = get(g:, 'VimuxRunnerName', '')
1414
let g:VimuxRunnerType = get(g:, 'VimuxRunnerType', 'pane')
1515
let g:VimuxTmuxCommand = get(g:, 'VimuxTmuxCommand', 'tmux')
1616
let g:VimuxUseNearest = get(g:, 'VimuxUseNearest', v:true)
17+
let g:VimuxExpandCommand = get(g:, 'VimuxExpandCommand', v:false)
1718

1819
function! VimuxOption(name) abort
1920
return get(b:, a:name, get(g:, a:name))
@@ -167,6 +168,9 @@ endfunction
167168
function! VimuxPromptCommand(...)
168169
let command = a:0 ==# 1 ? a:1 : ''
169170
let l:command = input(VimuxOption('VimuxPromptString'), command, 'shellcmd')
171+
if VimuxOption('VimuxExpandCommand')
172+
let l:command = join(map(split(l:command, ' '), 'expand(v:val)'), ' ')
173+
endif
170174
call VimuxRunCommand(l:command)
171175
endfunction
172176

0 commit comments

Comments
 (0)