├── License.md ├── README.md └── plugin └── run-interactive.vim /License.md: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2017 Chris Toomey 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | Run Interactive 2 | =============== 3 | 4 | Run Interactive is a Vim plugin for selectively running commands via an 5 | interactive shell. This allows you to take advantage of custom functions, 6 | aliases, etc that are configured via your login shell scripts. 7 | 8 | Vim supports treating the shell as an interactive shell, but this has 9 | [performance and maintenance concerns][]. This plugin allows for temporarily 10 | setting Vim to use an interactive shell, then returns to default 11 | non-interactive configuration after executing the specified command. 12 | 13 | It provides a single command, `RunInInteractiveShell`, which allows you to 14 | run a command via an interactive shell. For instance, assume you have a 15 | a git alias called `update` defined in your `~/.gitconfig`. By default you 16 | would not be able to run this command from within Vim, but with this plugin 17 | you can run it via: 18 | 19 | ``` vim 20 | :RunInInteractiveShell git update 21 | ``` 22 | 23 | [performance and maintenance concerns]: https://github.com/tpope/vim-sensible/issues/29 24 | 25 | Installation 26 | ------------ 27 | 28 | Install with [Vundle][] by adding the following line to your `vimrc`: 29 | 30 | ``` vim 31 | Bundle 'christoomey/vim-run-interactive' 32 | ``` 33 | 34 | And then run the `:BundleInstall` command from within Vim. 35 | 36 | [Vundle]: https://github.com/gmarik/Vundle.vim 37 | 38 | Usage 39 | ----- 40 | 41 | The main interface to the plugin is via the command, `RunInInteractiveShell`. 42 | This is obviously a bit of a mouthful, so a mapping like the following is 43 | recommended: 44 | 45 | ``` vim 46 | " Add this to your vimrc to provide a shortcut 47 | nnoremap ri :RunInInteractiveShell 48 | ``` 49 | 50 | Assuming you are using `,` as you `leader`, then you can type `,ri` in normal 51 | mode and the command name will be populated for you along with a trailing 52 | space. You can then enter your desired shell command and hit `enter` to run 53 | it. 54 | -------------------------------------------------------------------------------- /plugin/run-interactive.vim: -------------------------------------------------------------------------------- 1 | function! s:RunInInteractiveShell(command, bang) 2 | let saved_shellcmdflag = &shellcmdflag 3 | set shellcmdflag+=il 4 | try 5 | if a:bang 6 | silent execute '!clear' 7 | endif 8 | execute '!' . a:command 9 | finally 10 | execute 'set shellcmdflag=' . saved_shellcmdflag 11 | endtry 12 | endfunction 13 | 14 | command! -bang -nargs=1 RunInInteractiveShell call RunInInteractiveShell(, 0) 15 | --------------------------------------------------------------------------------