Open eshell in project root by default

If passed the universal arg (SPC u SPC o e) or (C-u M-x +eshell/open),
it will open in the current directory.
This commit is contained in:
Henrik Lissner 2018-06-18 14:42:42 +02:00
parent 08f01edafd
commit c8aba6f552
No known key found for this signature in database
GPG key ID: 5F6C0EA160557395

View file

@ -72,10 +72,11 @@
;;
;;;###autoload
(defun +eshell/open (&optional command)
(defun +eshell/open (arg &optional command)
"Open eshell in the current buffer."
(interactive)
(let ((buf (+eshell--buffer (eq major-mode 'eshell-mode))))
(interactive "P")
(let* ((default-directory (if arg default-directory (doom-project-root)))
(buf (+eshell--buffer (eq major-mode 'eshell-mode))))
(with-current-buffer buf
(unless (eq major-mode 'eshell-mode) (eshell-mode)))
(switch-to-buffer buf)
@ -84,10 +85,11 @@
(+eshell-run-command command))))
;;;###autoload
(defun +eshell/open-popup (&optional command)
(defun +eshell/open-popup (arg &optional command)
"Open eshell in a popup window."
(interactive)
(let ((buf (+eshell--buffer)))
(interactive "P")
(let* ((default-directory (if arg default-directory (doom-project-root)))
(buf (+eshell--buffer)))
(with-current-buffer buf
(unless (eq major-mode 'eshell-mode) (eshell-mode)))
(pop-to-buffer buf)
@ -96,10 +98,11 @@
(+eshell-run-command command))))
;;;###autoload
(defun +eshell/open-workspace (&optional command)
(defun +eshell/open-workspace (arg &optional command)
"Open eshell in a separate workspace. Requires the (:feature workspaces)
module to be loaded."
(interactive)
(interactive "P")
(let ((default-directory (if arg default-directory (doom-project-root))))
(unless (featurep! :feature workspaces)
(user-error ":feature workspaces is required, but disabled"))
(unless (+workspace-get "eshell" t)
@ -108,11 +111,11 @@ module to be loaded."
(doom-visible-windows)
:key #'window-buffer)))
(select-window (get-buffer-window buf))
(+eshell/open))
(+eshell/open arg))
(when command
(+eshell-run-command command))
(+eshell--set-window (selected-window) t)
(doom/workspace-display))
(doom/workspace-display)))
(defun +eshell-run-command (command)
(unless (cl-remove-if-not #'buffer-live-p +eshell-buffers)