I have the following code in my init.el
;;open eshell
(defun eshell-other-window ()
(interactive)
(let ((buf (eshell)))
(switch-to-buffer (other-buffer buf))
(switch-to-buffer-other-window buf)
)
)
(global-set-key (kbd "C-t") 'eshell-other-window)
This works fine until I exit eshell. When I exit, the window stays open. How do I get the window to close automatically?
The following answer assumes that the user is typing exit
at the command prompt in the *Eshell*
buffer followed by the return/enter key, and the answer assumes that the function eshell/exit
is doing its thing. [The user is still free to customize the variable eshell-kill-on-exit
to either burry or kill the *Eshell*
buffer when exiting.]
(require 'eshell)
(defun my-custom-func ()
(when (not (one-window-p))
(delete-window)))
(advice-add 'eshell-life-is-too-much :after 'my-custom-func)