diff --git a/nvim/.config/nvim/plugin/shell.vim b/nvim/.config/nvim/plugin/shell.vim new file mode 100644 index 0000000..bc67f88 --- /dev/null +++ b/nvim/.config/nvim/plugin/shell.vim @@ -0,0 +1,13 @@ +function! s:ExecuteInShell(command) " {{{ + let command = join(map(split(a:command), 'expand(v:val)')) + let winnr = bufwinnr('^' . command . '$') + silent! execute winnr < 0 ? 'tabedit ' . fnameescape(command) : winnr . 'wincmd w' + setlocal buftype=nowrite bufhidden=wipe nobuflisted noswapfile nowrap nonumber + silent! execute 'silent %!'. command + silent! redraw + silent! execute 'au BufUnload execute bufwinnr(' . bufnr('#') . ') . ''wincmd w''' + silent! execute 'nnoremap q :q' + echo 'Shell command ' . command . ' executed.' +endfunction " }}} + +command! -complete=shellcmd -nargs=+ Shell call s:ExecuteInShell()