Emacs:如何在启动时分割、在底部窗口中打开 shell?

Emacs:如何在启动时分割、在底部窗口中打开 shell?

我尝试将此代码片段添加到我的~/.emacs,但得到的缓冲区/窗口映射很奇怪。

;; Open split shell on launch
(add-hook 'after-init-hook
  (lambda ()
    (let ((w (split-window-below 2)))
      (select-window w)
      (sh))
      (switch-to-buffer "*shell*")))

例子:

$ emacs .

预期的:

  • 顶部窗口已损坏
  • 底部窗口是外壳

观察到的:

  • 顶部窗户有划痕
  • 底部窗口已损坏

答案1

感谢@lawlist:

;; Open split shell on launch
(add-hook 'emacs-startup-hook
  (lambda ()
    (let ((w (split-window-below 2)))
      (select-window w)
      (sh))
      (switch-to-buffer "*shell*")))

相关内容