dotfiles

My personal shell configs and stuff
git clone git://git.alex.balgavy.eu/dotfiles.git
Log | Files | Refs | Submodules | README | LICENSE

commit 0948f9c4e4112801777027b3e60945f76468aea5
parent 5a114d4f546ba4ff981067edad084f798a32e1e8
Author: Alex Balgavy <a.balgavy@gmail.com>
Date:   Fri, 12 Oct 2018 14:15:30 +0200

Redirect output of command to scratch buffer

Either a vim or external command. Both work.

Diffstat:
Mvim/commands.vimrc | 24++++++++++++++++++++++++
1 file changed, 24 insertions(+), 0 deletions(-)

diff --git a/vim/commands.vimrc b/vim/commands.vimrc @@ -11,6 +11,11 @@ command! Fuckwindows %s/ //g command! Hexedit %!xxd command! Unhex %!xxd -r +command! -nargs=1 -complete=command Redir silent call Redir(<f-args>) +" Usage: +" :Redir hi ............. show the full output of command ':hi' in a scratch window +" :Redir !ls -al ........ show the full output of command ':!ls -al' in a scratch window + " Functions function! InsertTabWrapper() let col = col('.') - 1 @@ -30,6 +35,25 @@ function! ToggleNumber() endif endfunc +function! Redir(cmd) + for win in range(1, winnr('$')) + if getwinvar(win, 'scratch') + execute win . 'windo close' + endif + endfor + if a:cmd =~ '^!' + execute "let output = system('" . substitute(a:cmd, '^!', '', '') . "')" + else + redir => output + execute a:cmd + redir END + endif + vnew + let w:scratch = 1 + setlocal nobuflisted buftype=nofile bufhidden=wipe noswapfile + call setline(1, split(output, "\n")) +endfunction + " Fat finger fixes/convenience abbreviations cnoreabbrev W! w! cnoreabbrev Q! q!