First open the preview window and set it to save the file automatically:
:botr pedit +:setl\ autoread /tmp/out.log
Now just run your command and send the output to a file.
:!date > /tmp/out.log 2>&1
The result of your command should appear in the preview window.
However, we still get the "Press ENTER" prompt. An easy way to avoid this is to create a display that presses Enter for us:
:nmap <Leader>r :exec '!date > /tmp/out.log 2>&1'<CR><CR><CR>
I thought it would take only two <CR>, but then I would need three.
source
share