Always display shell buffers at bottom of frame in dedicated window
Inspired by https://www.masteringemacs.org/article/demystifying-emacs-window-manager.
This commit is contained in:
parent
daa7882732
commit
aec896c939
|
@ -28,25 +28,24 @@
|
|||
;; idea to split the current window is from
|
||||
;; http://howardism.org/Technical/Emacs/eshell-fun.html
|
||||
(interactive "P")
|
||||
(if (string= "eshell-mode" major-mode)
|
||||
(if (derived-mode-p 'eshell-mode)
|
||||
;; bury buffer; reopen with current working directory if arg is given
|
||||
(progn
|
||||
(bury-buffer)
|
||||
(delete-window)
|
||||
(and arg (db/run-or-hide-eshell arg)))
|
||||
(if-let ((eshell-window (db/find-window-by-buffer-mode 'eshell-mode)))
|
||||
(select-window eshell-window)
|
||||
;; open eshell
|
||||
(let ((current-dir (expand-file-name default-directory))
|
||||
(height (/ (window-total-height) 3)))
|
||||
(split-window-vertically (- height))
|
||||
(other-window 1)
|
||||
(let* ((current-dir (expand-file-name default-directory))
|
||||
(height (/ (frame-text-lines) 3)))
|
||||
(select-window (split-window (frame-root-window) (- height) 'below))
|
||||
(eshell 1)
|
||||
(when arg
|
||||
(end-of-line)
|
||||
(eshell-kill-input)
|
||||
(insert (format "cd '%s'" current-dir))
|
||||
(eshell-send-input))))))
|
||||
(eshell-send-input))))
|
||||
(set-window-dedicated-p (selected-window) t)))
|
||||
|
||||
(defun eshell-clear-buffer ()
|
||||
"Clear terminal."
|
||||
|
|
|
@ -75,15 +75,15 @@ If already in `*ansi-term*' buffer, bury it."
|
|||
(if-let ((shell-window (db/find-window-by-buffer-mode 'shell-mode)))
|
||||
(select-window shell-window)
|
||||
;; open shell in buffer with height of ⅓ of current window
|
||||
(let ((height (/ (window-total-height) 3)))
|
||||
(shell)
|
||||
(enlarge-window (- height (window-total-height)))))))
|
||||
(let ((height (/ (frame-text-lines) 3)))
|
||||
(select-window (split-window (frame-root-window) (- height) 'below))
|
||||
(shell)))
|
||||
(set-window-dedicated-p (selected-window) t)))
|
||||
(if (not arg)
|
||||
;; toggle shell window
|
||||
(if (not (derived-mode-p 'shell-mode))
|
||||
(change-to-shell)
|
||||
(bury-buffer)
|
||||
(delete-window))
|
||||
(bury-buffer))
|
||||
|
||||
;; unconditionally go to shell, and also change to cwd
|
||||
(let ((current-dir (expand-file-name default-directory)))
|
||||
|
|
Loading…
Reference in New Issue