More eshell window management tweaks
This commit is contained in:
@@ -512,7 +512,7 @@
|
||||
"\\*Flycheck errors\\*"
|
||||
help-mode
|
||||
compilation-mode
|
||||
"\\*eshell-popup\\*" eshell-mode))
|
||||
"\\*eshell-popup\\*"))
|
||||
|
||||
(defun my/popper-window-height (window)
|
||||
"Make eshell popups take half the frame height, otherwise defer to popper--fit-window-height"
|
||||
@@ -939,8 +939,41 @@
|
||||
when (string-match regexp (buffer-name (window-buffer window)))
|
||||
thereis window))
|
||||
|
||||
(defun my/split-largest-eshell-and-focus ()
|
||||
"Find the largest eshell window in the current frame, split it
|
||||
along its longest dimension, and create a new eshell in the
|
||||
split. The new eshell uses the `default-directory` of the
|
||||
buffer that was current when this command was invoked. Finally,
|
||||
the new eshell window is selected."
|
||||
(interactive)
|
||||
(let* ((starting-dir default-directory)
|
||||
(largest-eshell-window
|
||||
(cl-loop with max-area = 0
|
||||
with largest-win = nil
|
||||
for win in (window-list)
|
||||
when (with-current-buffer (window-buffer win)
|
||||
(eq major-mode 'eshell-mode))
|
||||
do (let ((area (* (window-total-width win) (window-total-height win))))
|
||||
(when (> area max-area)
|
||||
(setq max-area area)
|
||||
(setq largest-win win)))
|
||||
finally return largest-win))
|
||||
|
||||
(new-window
|
||||
(with-selected-window largest-eshell-window
|
||||
(if (> (window-total-width) (* 2 (window-total-height)))
|
||||
(split-window-right)
|
||||
(split-window-below)))))
|
||||
|
||||
(select-window new-window)
|
||||
(let ((default-directory starting-dir))
|
||||
(eshell t))))
|
||||
; (select-window new-window)))
|
||||
|
||||
(use-package eshell
|
||||
:bind (("M-`" . my/eshell-toggle))
|
||||
:bind (("M-`" . my/eshell-toggle)
|
||||
:map eshell-mode-map
|
||||
("C-S-<return>" . my/split-largest-eshell-and-focus))
|
||||
:config
|
||||
(setq eshell-destroy-buffer-when-process-dies t
|
||||
eshell-scroll-to-bottom-on-input t
|
||||
|
||||
Reference in New Issue
Block a user