我的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)
这工作正常,直到我退出 eshell。当我退出时,窗口保持打开状态。如何让窗口自动关闭?
以下答案假定用户在命令提示符处键入*Eshell*
缓冲区中的exit
,后跟返回/输入键,答案假定函数eshell/exit
正在执行其操作。 [用户仍然可以自由自定义变量eshell-kill-on-exit
,以便在退出时破坏或杀死*Eshell*
缓冲区。
(require 'eshell)
(defun my-custom-func ()
(when (not (one-window-p))
(delete-window)))
(advice-add 'eshell-life-is-too-much :after 'my-custom-func)