diff --git a/doc/vimux.txt b/doc/vimux.txt index b0ad5e0..6b2e1f1 100644 --- a/doc/vimux.txt +++ b/doc/vimux.txt @@ -15,6 +15,7 @@ CONTENTS *vimux-contents* 2.5 .............................. |VimuxInterruptRunner| 2.6 .............................. |VimuxClearRunnerHistory| 2.7 .............................. |VimuxZoomRunner| + 2.8 .............................. |VimuxRunCommandInDir| 3. Misc ............................ |VimuxMisc| 3.1 Example Keybinding............ |VimuxExampleKeybinding| 3.2 Tslime Replacement............ |VimuxTslimeReplacement| @@ -71,6 +72,7 @@ Furthermore there are several handy commands all starting with 'Vimux': - |VimuxPromptCommand| - |VimuxClearRunnerHistory| - |VimuxZoomRunner| + - |VimuxRunCommandInDir| ------------------------------------------------------------------------------ *VimuxRunCommand* @@ -193,6 +195,23 @@ Zoom requires tmux version >= 1.8 map vz :VimuxZoomRunner < +------------------------------------------------------------------------------ + *VimuxRunCommandInDir* +VimuxRunCommandInDir~ + +Runs the specified command inside the directory of +the currently opened file. Takes two arguments. command and inFile + +command: The command to run +inFile: If 1 the filename will be appended to the command +> + + " Compile currently opened latex file to pdf + autocmd Filetype tex nnoremap rr :update:call VimuxRunCommandInDir('latexmk -pdf', 1) + " Push the repository of the currently opened file + nnoremap gp :call VimuxRunCommandInDir("git push", 0) +< + ============================================================================== MISC (3) *VimuxMisc* @@ -325,7 +344,7 @@ The type of view object Vimux should use for the runner. For reference, a tmux session is a group of windows, and a window is a layout of panes. let g:VimuxRunnerType = "window" - + Options: "pane": for panes "window": for windows diff --git a/plugin/vimux.vim b/plugin/vimux.vim index 8c60be4..e0bf981 100644 --- a/plugin/vimux.vim +++ b/plugin/vimux.vim @@ -15,6 +15,14 @@ command -nargs=? VimuxPromptCommand :call VimuxPromptCommand() command VimuxClearRunnerHistory :call VimuxClearRunnerHistory() command VimuxTogglePane :call VimuxTogglePane() +function! VimuxRunCommandInDir(command, useFile) + let l:file = "" + if a:useFile ==# 1 + let l:file = shellescape(expand('%:t'), 1) + endif + call VimuxRunCommand("cd ".shellescape(expand('%:p:h'), 1)." && ".a:command." ".l:file) +endfunction + function! VimuxRunLastCommand() if exists("g:VimuxRunnerIndex") call VimuxRunCommand(g:VimuxLastCommand)