Reputation: 7059
Given something like this:
(global-set-key (kbd "<f4>") (lambda () (interactive) (shell-command "gcc --version")))
Is there a way to get the output to always go into a "new or existing window on the right" versus sometimes doing that, and sometimes putting the output in a little window below the status and command areas (two different possibilities shown below)?
Upvotes: 0
Views: 247
Reputation: 5198
The following works reliable also for one line of output (e.g. "echo hello"
instead of "gcc --version"
):
(global-set-key (kbd "<f4>")
(lambda () (interactive)
(with-current-buffer (get-buffer-create "*Shell Command Output*")
(erase-buffer)
(insert (shell-command-to-string "gcc --version"))
(display-buffer (current-buffer)))))
Upvotes: 1