From 1170fbe39d6ac2cc0c516ede8014bd6025c0c490 Mon Sep 17 00:00:00 2001 From: benmills Date: Wed, 29 Feb 2012 12:44:13 -0600 Subject: [PATCH] Add InspectVimTmuxRunner command and PromptVimTmuxCommand --- README.mkd | 24 ++++++++++++++++++++++-- plugin/vimux.vim | 16 ++++++++++++++++ 2 files changed, 38 insertions(+), 2 deletions(-) diff --git a/README.mkd b/README.mkd index 7ba7b8a..74da2ba 100644 --- a/README.mkd +++ b/README.mkd @@ -17,7 +17,17 @@ Run a system command in a small horizontal split bellow the current pane vim is ```viml " Run the current file with rspec -map rb :call RunVimTmuxCommand("clear %% rspec " . bufname("%")) +map rb :call RunVimTmuxCommand("clear && rspec " . bufname("%")) +``` + +### PromptVimTmuxCommand +Prompt for a command and run it in a small horizontal split bellow the current pane. + +*Example:* + +```viml +" Prompt for a command to run +map rp :PromptVimTmuxCommand ``` ### RunLastVimTmuxCommand @@ -30,6 +40,16 @@ Run the last command executed by `RunVimTmuxCommand` map rl :call RunLastVimTmuxCommand ``` +### InspectVimTmuxRunner +Move into the tmux runner pane created by `RunVimTmuxCommand` and enter copy mode (scroll mode). + +*Example:* + +```viml +" Inspect runner pane +map ri :InspectVimTmuxRunner +``` + ### CloseVimTmuxWindows Close all other tmux panes in the current window. @@ -54,4 +74,4 @@ let VimuxHeight = "50" The features I would like to add in the near future. -* Add the ability to target any tmux session, window and pane \ No newline at end of file +* Add the ability to target any tmux session, window and pane diff --git a/plugin/vimux.vim b/plugin/vimux.vim index 11dafb0..1868040 100644 --- a/plugin/vimux.vim +++ b/plugin/vimux.vim @@ -4,6 +4,8 @@ end command RunLastVimTmuxCommand :call RunLastVimTmuxCommand() command CloseVimTmuxWindows :call CloseVimTmuxWindows() +command InspectVimTmuxRunner :call InspectVimTmuxRunner() +command PromptVimTmuxCommand :call PromptVimTmuxCommand() function! RunVimTmuxCommand(command) let g:_VimTmuxCmd = a:command @@ -29,6 +31,15 @@ function! CloseVimTmuxWindows() call ClearVimTmuxWindow() endfunction +function! InspectVimTmuxRunner() + ruby CurrentTmuxSession.new.inspect_runner +endfunction + +function! PromptVimTmuxCommand() + let l:command = input("Command? ") + call RunVimTmuxCommand(l:command) +endfunction + ruby << EOF class TmuxSession def initialize(session, window, pane) @@ -62,6 +73,11 @@ class TmuxSession end end + def inspect_runner + run("select-pane -t #{target(:pane => runner_pane)}") + run("copy-mode") + end + def current_panes run('list-panes').split("\n").map do |line| line.split(':').first