-
Notifications
You must be signed in to change notification settings - Fork 0
/
reshell.el
47 lines (40 loc) · 1.38 KB
/
reshell.el
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
;; Author: Reion Wong <[email protected]>
;; Maintainer: Reion Wong <[email protected]>
;; Created: 2022-07-05
;; Last-Updated: 2022/07/05 12:45:00
;; Keywords: eshell
;; Compatibility: GNU Emacs 27
(require 'eshell)
(defvar reshell-buffer-name "*eshell*")
(defvar reshell-mode-func '(lambda () (eshell)))
(defvar reshell-buffer-height 25)
(defvar reshell-last-buffer nil)
(defvar reshell-last-window nil)
(defun reshell ()
(interactive)
(if (equal (buffer-name) reshell-buffer-name)
(reshell-popout)
(reshell-popup)))
(defun reshell-popup ()
(let ((w (get-buffer-window reshell-buffer-name)))
(if w
(select-window w)
(progn
(setq reshell-last-buffer (buffer-name))
(setq reshell-last-window (selected-window))
(if (not (eq reshell-buffer-height 100))
(progn
(split-window (selected-window)
(round (* (window-height) (/ (- 100 reshell-buffer-height) 100.0))))
(other-window 1)))
(if (not (get-buffer reshell-buffer-name))
(funcall (eval reshell-mode-func))
(switch-to-buffer reshell-buffer-name))))))
(defun reshell-popout ()
(if (not (eq reshell-buffer-height 100))
(progn
(delete-window)
(select-window reshell-last-window)
))
(switch-to-buffer reshell-last-buffer))
(provide 'reshell)