Return to shell output from last run shell command

151 Views Asked by At

I run my tests file like such:

:!bundle exec rspec my_file_spec.rb

When I run that command it displays my test results in another window and I get "Press ENTER or type command to continue" to return back to vim. That's all working.

What I'd like to do though is get back to that previous output once I've left it. Is that at all possible?

I don't see it in my list of buffers and I really don't need to keep the output in a separate window/split.

1

There are 1 best solutions below

0
On BEST ANSWER

The output from the :! command is printed directly to the terminal (or GVIM's built-in emulator); it is not saved. To do that, you could redirect into an external file with tee:

:!bundle exec rspec my_file_spec.rb | tee a.out
:split a.out

Or, you directly open a scratch buffer and :read in the command's output:

:new +setl\ buftype=nofile | 0read !bundle exec rspec my_file_spec.rb

The downside of this is that you only see the output once the external command concludes.