benmills/vimux — pull request #41 by duwanis (2012-09-05 01:58:16+00:00)
Title: Add function for gracefully degrading commands

I had a feature request for vimux and thought I would just put together a pull request rather than open up an issue. Hope you don't mind, @benmills.

Since I started using vimux, I've been gradually replacing a lot of my old keybindings that interact with the shell environment with calls to RunVimuxCommand. Unfortunately, I'm not always *in* a tmux session, so I've found myself often writing custom functions that look like:

```
function TMDoStuff()
if InTmux()
VimuxRunCommand("command")
else
exec "!command"
endif
endfunction
```

It seems reasonable to me that this is functionality Vimux might provide by default, so I added a new function that generalizes this pattern: `VimuxRunCommandOrFallback`. The above function can now be handled with a single mapping:

`map :call VimuxRunCommandOrFallback("command")`

...which will execute `command` in vimux if possible, and will otherwise execute `command` using vim's normal shell interaction (the `!` command).

Hopefully this is useful.

Oh, and in any event, thanks a lot for writing/maintaining this plugin. It's a fantastic aide to my development process :)