From cd0aa7cc7d59c270aaa450a22bdc045094f57f91 Mon Sep 17 00:00:00 2001 From: Chris Toomey Date: Thu, 22 Nov 2012 23:12:17 -0500 Subject: [PATCH] Initial OpenRunnerPane implementation --- README.mkd | 6 +++++- plugin/vim-tmux-runner.vim | 39 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 44 insertions(+), 1 deletion(-) create mode 100644 plugin/vim-tmux-runner.vim diff --git a/README.mkd b/README.mkd index 2a2b9f7..7f8444e 100644 --- a/README.mkd +++ b/README.mkd @@ -2,7 +2,11 @@ A simple, vimscript only, command runner for sending commands from vim to tmux -Inspired by: +## Commands + +This plugin exposes a command to open a small command runner window + +## Inspiration - Tslime.vim - Vimux diff --git a/plugin/vim-tmux-runner.vim b/plugin/vim-tmux-runner.vim new file mode 100644 index 0000000..ceb4f6a --- /dev/null +++ b/plugin/vim-tmux-runner.vim @@ -0,0 +1,39 @@ +" Function: s:initVariable() function {{{2 +" This function is used to initialise a given variable to a given value. The +" variable is only initialised if it does not exist prior +" +" Args: +" var: the name of the var to be initialised +" value: the value to initialise var to +" +" Returns: +" 1 if the var is set, 0 otherwise +function! s:initVariable(var, value) + if !exists(a:var) + exec 'let ' . a:var . ' = ' . "'" . substitute(a:value, "'", "''", "g") . "'" + return 1 + endif + return 0 +endfunction + +function! s:OpenRunnerPane() + call s:CacheVimTmuxPane() + call system("tmux split-window -p 20 -v") + call s:RefocusVimPane() +endfunction + +function! s:CacheVimTmuxPane() + let panes = system("tmux list-panes") + for pane_title in split(panes, '\n') + if pane_title =~ '\(active\)' + let s:cached_vim_pane = pane_title[0] + echo s:cached_vim_pane + endif + endfor +endfunction + +function! s:RefocusVimPane() + call system("tmux select-pane -t " . s:cached_vim_pane) +endfunction + +command! VimTmuxRunnerOpenRunner :call s:OpenRunnerPane()