Rewrite eshell config
This commit is contained in:
parent
2672d4b4cd
commit
9c2e59e231
4 changed files with 105 additions and 44 deletions
|
@ -3,8 +3,22 @@
|
|||
(require 'eshell)
|
||||
|
||||
(defvar doom-eshell-buffers '() "")
|
||||
(defvar doom-eshell-height 16 "")
|
||||
(defvar-local doom-eshell-direction nil "")
|
||||
|
||||
;;;###autoload
|
||||
(defun doom|eshell-cleanup ()
|
||||
(when (eq major-mode 'eshell-mode)
|
||||
(setq doom-eshell-buffers (delete (current-buffer) doom-eshell-buffers))
|
||||
(cond ((doom/popup-p)
|
||||
(delete-window))
|
||||
((string= "eshell" (wg-workgroup-name (wg-current-workgroup t)))
|
||||
(if (one-window-p)
|
||||
(doom:workgroup-delete)
|
||||
(delete-window))))))
|
||||
|
||||
;;;###autoload
|
||||
(defun doom|eshell-init ()
|
||||
(when (eq major-mode 'eshell-mode)
|
||||
(add-to-list 'doom-eshell-buffers (current-buffer))))
|
||||
|
||||
(defun doom--eshell-outside-prompt-p (&optional offset)
|
||||
(< (point) eshell-last-output-end))
|
||||
|
@ -20,39 +34,14 @@
|
|||
;;;###autoload
|
||||
(defun doom/eshell-split ()
|
||||
(interactive)
|
||||
(select-window (split-window-vertically doom-eshell-height))
|
||||
(setq-local doom-eshell-direction 'below)
|
||||
(doom--eshell-init t))
|
||||
(select-window (split-window-vertically))
|
||||
(doom:eshell))
|
||||
|
||||
;;;###autoload
|
||||
(defun doom/eshell-vsplit ()
|
||||
(interactive)
|
||||
(select-window (split-window-horizontally))
|
||||
(setq-local doom-eshell-direction 'right)
|
||||
(doom--eshell-init t))
|
||||
|
||||
;;;###autoload
|
||||
(defun doom/eshell (&optional same &rest _)
|
||||
(interactive)
|
||||
(doom--eshell-init same)
|
||||
;; (if doom-eshell-buffers
|
||||
;; (let* ((buf (car (reverse doom-eshell-buffers)))
|
||||
;; (win (get-buffer-window buf)))
|
||||
;; (if (and win (window-live-p win))
|
||||
;; (select-window win)
|
||||
;; (select-window (split-window-vertically doom-eshell-height))
|
||||
;; (evil-window-move-very-bottom)
|
||||
;; (switch-to-buffer buf t t)))
|
||||
;; (doom--eshell-init same))
|
||||
)
|
||||
|
||||
(defun doom--eshell-init (&optional same)
|
||||
(unless same (select-window (split-window)))
|
||||
(eshell (max 0 (1- (length doom-eshell-buffers))))
|
||||
(unless same
|
||||
(evil-window-move-very-bottom)
|
||||
(evil-window-set-height doom-eshell-height))
|
||||
(set-window-dedicated-p (selected-window) t))
|
||||
(doom:eshell))
|
||||
|
||||
;;;###autoload
|
||||
(defun doom/eshell-prompt ()
|
||||
|
@ -60,6 +49,39 @@
|
|||
(propertize (doom--eshell-current-git-branch) 'face 'font-lock-function-name-face)
|
||||
(propertize " λ " 'face 'font-lock-constant-face)))
|
||||
|
||||
;;;###autoload (autoload 'doom:eshell "defuns-eshell" nil t)
|
||||
(evil-define-command doom:eshell (&optional bang)
|
||||
"Create a shell in the current buffer. If BANG, use a popup buffer."
|
||||
(interactive "<!>")
|
||||
(let ((buf (if bang
|
||||
(get-buffer-create "*eshell:popup*")
|
||||
(generate-new-buffer eshell-buffer-name))))
|
||||
(with-current-buffer buf
|
||||
(unless (eq major-mode 'eshell-mode) (eshell-mode)))
|
||||
(if bang
|
||||
(doom/popup-buffer buf)
|
||||
(pop-to-buffer-same-window buf))))
|
||||
|
||||
;;;###autoload
|
||||
(defun doom/eshell-tab ()
|
||||
"Create a separate tab for the shell."
|
||||
(interactive)
|
||||
(unless (wg-switch-to-workgroup (wg-get-workgroup "eshell" t) t)
|
||||
(doom:tab-create nil "eshell"))
|
||||
(let ((buf (--find (string-match-p "^\\*eshell" (buffer-name (window-buffer it)))
|
||||
(doom/get-visible-windows))))
|
||||
(if buf
|
||||
(select-window (get-buffer-window buf))
|
||||
(doom:eshell))
|
||||
(doom/workgroup-display)))
|
||||
|
||||
;;;###autoload
|
||||
(defun doom/eshell-frame ()
|
||||
"Create a separate frame for the shell."
|
||||
(interactive)
|
||||
(doom/new-frame)
|
||||
(doom:eshell))
|
||||
|
||||
;;;###autoload
|
||||
(defun doom/eshell-evil-append ()
|
||||
(interactive)
|
||||
|
@ -100,5 +122,19 @@
|
|||
(user-error "Cannot edit read-only region")
|
||||
(call-interactively 'evil-replace-state)))
|
||||
|
||||
;;;###autoload
|
||||
(defun doom/eshell-evil-change ()
|
||||
(interactive)
|
||||
(when (doom--eshell-outside-prompt-p)
|
||||
(goto-char eshell-last-output-end))
|
||||
(call-interactively 'evil-change))
|
||||
|
||||
;;;###autoload
|
||||
(defun doom/eshell-evil-change-line ()
|
||||
(interactive)
|
||||
(when (doom--eshell-outside-prompt-p)
|
||||
(goto-char eshell-last-output-end))
|
||||
(call-interactively 'evil-change-line))
|
||||
|
||||
(provide 'defuns-eshell)
|
||||
;;; defuns-eshell.el ends here
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue