Skip to content

Commit a991ce8

Browse files
committed
Merge pull request #116 from hpurmann/VimuxRunCommandInDir
Added VimuxRunCommandInDir + doc
2 parents 50254fa + 7b655a7 commit a991ce8

File tree

2 files changed

+28
-1
lines changed

2 files changed

+28
-1
lines changed

doc/vimux.txt

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ CONTENTS *vimux-contents*
1515
2.5 .............................. |VimuxInterruptRunner|
1616
2.6 .............................. |VimuxClearRunnerHistory|
1717
2.7 .............................. |VimuxZoomRunner|
18+
2.8 .............................. |VimuxRunCommandInDir|
1819
3. Misc ............................ |VimuxMisc|
1920
3.1 Example Keybinding............ |VimuxExampleKeybinding|
2021
3.2 Tslime Replacement............ |VimuxTslimeReplacement|
@@ -71,6 +72,7 @@ Furthermore there are several handy commands all starting with 'Vimux':
7172
- |VimuxPromptCommand|
7273
- |VimuxClearRunnerHistory|
7374
- |VimuxZoomRunner|
75+
- |VimuxRunCommandInDir|
7476

7577
------------------------------------------------------------------------------
7678
*VimuxRunCommand*
@@ -193,6 +195,23 @@ Zoom requires tmux version >= 1.8
193195
map <Leader>vz :VimuxZoomRunner<CR>
194196
<
195197

198+
------------------------------------------------------------------------------
199+
*VimuxRunCommandInDir*
200+
VimuxRunCommandInDir~
201+
202+
Runs the specified command inside the directory of
203+
the currently opened file. Takes two arguments. command and inFile
204+
205+
command: The command to run
206+
inFile: If 1 the filename will be appended to the command
207+
>
208+
209+
" Compile currently opened latex file to pdf
210+
autocmd Filetype tex nnoremap <buffer> <Leader>rr :update<Bar>:call VimuxRunCommandInDir('latexmk -pdf', 1)<CR>
211+
" Push the repository of the currently opened file
212+
nnoremap <leader>gp :call VimuxRunCommandInDir("git push", 0)<CR>
213+
<
214+
196215
==============================================================================
197216
MISC (3) *VimuxMisc*
198217

@@ -325,7 +344,7 @@ The type of view object Vimux should use for the runner. For reference, a
325344
tmux session is a group of windows, and a window is a layout of panes.
326345

327346
let g:VimuxRunnerType = "window"
328-
347+
329348
Options:
330349
"pane": for panes
331350
"window": for windows

plugin/vimux.vim

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,14 @@ command -nargs=? VimuxPromptCommand :call VimuxPromptCommand(<args>)
1515
command VimuxClearRunnerHistory :call VimuxClearRunnerHistory()
1616
command VimuxTogglePane :call VimuxTogglePane()
1717

18+
function! VimuxRunCommandInDir(command, useFile)
19+
let l:file = ""
20+
if a:useFile ==# 1
21+
let l:file = shellescape(expand('%:t'), 1)
22+
endif
23+
call VimuxRunCommand("cd ".shellescape(expand('%:p:h'), 1)." && ".a:command." ".l:file." && cd - > /dev/null")
24+
endfunction
25+
1826
function! VimuxRunLastCommand()
1927
if exists("g:VimuxRunnerIndex")
2028
call VimuxRunCommand(g:VimuxLastCommand)

0 commit comments

Comments
 (0)