         (format " [%s]" (substring branch 2))
       "")))
 
-(defun +eshell-delete-window ()
-  (if (one-window-p)
-      (unless (doom-real-buffer-p (progn (previous-buffer) (current-buffer)))
-        (switch-to-buffer (doom-fallback-buffer)))
-    (delete-window)))
-
-(defun +eshell-get-or-create-buffer ()
-  (or (cl-loop for buf in (ring-elements +eshell-buffers)
-               if (and (buffer-live-p buf)
-                       (not (get-buffer-window buf)))
-               return buf)
+(defun +eshell--buffer (&optional new-p)
+  (or (unless new-p
+        (cl-loop for buf in (ring-elements +eshell-buffers)
+                 if (and (buffer-live-p buf)
+                         (not (get-buffer-window buf)))
+                 return buf))
       (generate-new-buffer +eshell-buffer-name)))
 
 ;;;###autoload

(defun +eshell/open-popup (&optional command)
  "Open eshell in a popup window."
  (interactive)
  (let ((buf (+eshell-get-or-create-buffer)))
    (with-current-buffer buf
      (unless (eq major-mode 'eshell-mode) (eshell-mode)))
    (pop-to-buffer buf)

(defun +eshell/open (&optional command)
  "Open eshell in the current buffer."
  (interactive)
  (let ((buf (+eshell--buffer (eq major-mode 'eshell-mode))))
    (with-current-buffer buf
      (unless (eq major-mode 'eshell-mode) (eshell-mode)))
    (switch-to-buffer buf)
