     (with-current-buffer buf
       (unless (eq major-mode 'eshell-mode) (eshell-mode)))
     (pop-to-buffer buf)
+    (+eshell--set-window (get-buffer-window buf) t)
     (when command
       (+eshell-run-command command))))
 

    (dolist (buf (ring-elements +eshell-buffers))
      (unless (buffer-live-p buf)
        (+eshell--remove-buffer buf)))
    (let ((window (selected-window)))
      (set-window-parameter window 'no-other-window t)
      (set-window-parameter window 'visible t)
      (set-window-dedicated-p window t))
    (+eshell--add-buffer buf)
    (setq +eshell-last-buffer buf)))

;;;###autoload
(defun +eshell|cleanup ()
  "Close window (or workspace) on quit."
  (let ((window (selected-window)))
    (set-window-parameter window 'no-other-window nil)
    (set-window-parameter window 'visible t)
    (set-window-dedicated-p window nil))
  (+eshell--remove-buffer (current-buffer))
  (cond ((and (featurep! :feature workspaces)
              (string= "eshell" (+workspace-current-name)))
         (+workspace/delete "eshell"))
        ((one-window-p)
         (unless (doom-real-buffer-p (progn (previous-buffer) (current-buffer)))
           (switch-to-buffer (doom-fallback-buffer))))
        ((delete (current-buffer) (get-buffer-window-list))
         (delete-window))))


;;


(defun +eshell--remove-buffer (buf)
  (when-let* ((idx (ring-member +eshell-buffers buf)))
    (ring-remove +eshell-buffers idx)
    t))

(defun +eshell--current-git-branch ()
  (let ((branch (car (cl-loop for match in (split-string (shell-command-to-string "git branch") "\n")
