Easily interact with tmux from vim. This project is still in development, so some features are still missing.
What inspired me to write vimux was tslime.vim, a plugin that lets you send input to tmux. While tslime.vim works well, I felt it wasn't optimized for my primary use case which was having a smaller tmux pane that I would use to run tests or play with a REPL.
My goal with vimux is to make interacting with tmux from vim effortless. By default when you call
RunVimTmuxCommand vimux will create a 20% tall horizontal pane under your current tmux pane and execute a command in it without losing focus of vim. Once that pane exists whenever you call
RunVimTmuxCommand again the command will be executed in that pane. As I was using vimux myself I wanted to rerun commands over and over. An example of this was running the current file through rspec. Rather than typing that over and over I wrote
RunLastVimTmuxCommand that will execute the last command you called with
Other auxiliary functions and the ones I talked about above can be found bellow with a full description and example key binds for your vimrc.
vim-bundle install benmills/vimux
- vimux-ruby-test a set of commands to easily run ruby tests
- vimux-cucumber run Cucumber Features through Vimux
Run a system command in a small horizontal split bellow the current pane vim is in.
" Run the current file with rspec map <Leader>rb :call RunVimTmuxCommand("clear; rspec " . bufname("%"))<CR>
Prompt for a command and run it in a small horizontal split bellow the current pane.
" Prompt for a command to run map <Leader>rp :PromptVimTmuxCommand<CR>
Run the last command executed by
" Run last command executed by RunVimTmuxCommand map <Leader>rl :RunLastVimTmuxCommand<CR>
Move into the tmux runner pane created by
RunVimTmuxCommand and enter copy mode (scroll mode).
" Inspect runner pane map <Leader>ri :InspectVimTmuxRunner<CR>
Close all other tmux panes in the current window.
" Close all other tmux panes in current window map <Leader>rx :CloseVimTmuxPanes<CR>
Interrupt any command that is running inside the runner pane.
" Interrupt any command running in the runner pane map <Leader>rs :InterruptVimTmuxRunner<CR>
Full Keybind Example
" Run the current file with rspec map <Leader>rb :call RunVimTmuxCommand("clear; rspec " . bufname("%"))<CR> " Prompt for a command to run map <Leader>rp :PromptVimTmuxCommand<CR> " Run last command executed by RunVimTmuxCommand map <Leader>rl :RunLastVimTmuxCommand<CR> " Inspect runner pane map <Leader>ri :InspectVimTmuxRunner<CR> " Close all other tmux panes in current window map <Leader>rx :CloseVimTmuxPanes<CR> " Interrupt any command running in the runner pane map <Leader>rs :InterruptVimTmuxRunner<CR>
Here is how to use vimux to send code to a REPL. This is similar to tslime. First, add some helpful mappings.
" Prompt for a command to run map <LocalLeader>vp :PromptVimTmuxCommand<CR> " If text is selected, save it in the v buffer and send that buffer it to tmux vmap <LocalLeader>vs "vy :call RunVimTmuxCommand(@v)<CR> " Select current paragraph and send it to tmux nmap <LocalLeader>vs vip<LocalLeader>vs<CR>
Now, open a clojure file. Let's say your leader is backslash (). Type \vp, and then type lein repl at the prompt. This opens a tmux split running a REPL. Then, select text or put the cursor on a function and type \vs. This will send it to the REPL and evaluate it.
Set the percent height of the runner pane opened by
let VimuxHeight = "50"
Set the default position of the runner pane.
let VimuxOrientation = "h"
Use nearest pane (not used by vim) if found instead of running split-window. Useful if you always have two panes opened and you want Vimux to use the existing one.
let VimuxUseNearestPane = 1